2003-10-22 18:07:59 +08:00
|
|
|
/* cygserver_ipc.h
|
|
|
|
|
2015-01-20 01:42:04 +08:00
|
|
|
Copyright 2002, 2003, 2004, 2012, 2013, 2014, 2015 Red Hat, Inc.
|
2003-10-22 18:07:59 +08:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef __CYGSERVER_IPC_H__
|
|
|
|
#define __CYGSERVER_IPC_H__
|
|
|
|
|
|
|
|
/*
|
2003-11-20 02:50:23 +08:00
|
|
|
* Datastructure which is part of any IPC input parameter block.
|
2003-10-22 18:07:59 +08:00
|
|
|
*/
|
2003-11-20 02:50:23 +08:00
|
|
|
struct vmspace {
|
|
|
|
void *vm_map; /* UNUSED */
|
|
|
|
struct shmmap_state *vm_shm;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct proc {
|
|
|
|
pid_t cygpid;
|
|
|
|
DWORD winpid;
|
2013-04-23 17:44:36 +08:00
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2003-11-20 02:50:23 +08:00
|
|
|
int gidcnt;
|
2013-04-23 17:44:36 +08:00
|
|
|
gid_t *gidlist;
|
2003-11-20 02:50:23 +08:00
|
|
|
bool is_admin;
|
|
|
|
struct vmspace *p_vmspace;
|
2004-02-07 00:18:59 +08:00
|
|
|
HANDLE signal_arrived;
|
2003-11-20 02:50:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __INSIDE_CYGWIN__
|
2012-03-20 04:18:18 +08:00
|
|
|
#include "sigproc.h"
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline void
|
2014-04-07 19:25:58 +08:00
|
|
|
ipc_set_proc_info (proc &blk, bool in_fork = false)
|
2003-11-20 02:50:23 +08:00
|
|
|
{
|
|
|
|
blk.cygpid = getpid ();
|
|
|
|
blk.winpid = GetCurrentProcessId ();
|
|
|
|
blk.uid = geteuid32 ();
|
|
|
|
blk.gid = getegid32 ();
|
|
|
|
blk.gidcnt = 0;
|
|
|
|
blk.gidlist = NULL;
|
|
|
|
blk.is_admin = false;
|
2015-11-27 21:39:11 +08:00
|
|
|
blk.signal_arrived = in_fork ? NULL : _my_tls.get_signal_arrived (true);
|
2003-11-20 02:50:23 +08:00
|
|
|
}
|
|
|
|
#endif /* __INSIDE_CYGWIN__ */
|
|
|
|
|
|
|
|
#ifndef __INSIDE_CYGWIN__
|
|
|
|
class ipc_retval {
|
|
|
|
private:
|
|
|
|
union {
|
|
|
|
int i;
|
2013-04-23 17:44:36 +08:00
|
|
|
ssize_t ssz;
|
|
|
|
size_t sz;
|
2003-11-20 02:50:23 +08:00
|
|
|
vm_offset_t off;
|
|
|
|
vm_object_t obj;
|
2003-10-22 18:07:59 +08:00
|
|
|
};
|
|
|
|
|
2003-11-20 02:50:23 +08:00
|
|
|
public:
|
2015-01-20 01:42:04 +08:00
|
|
|
ipc_retval () { ssz = 0; }
|
2013-07-19 19:32:54 +08:00
|
|
|
ipc_retval (ssize_t nssz) { ssz = nssz; }
|
2003-10-22 18:07:59 +08:00
|
|
|
|
2003-11-20 02:50:23 +08:00
|
|
|
operator int () const { return i; }
|
|
|
|
int operator = (int ni) { return i = ni; }
|
2003-10-22 18:07:59 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifndef __x86_64__
|
|
|
|
/* On x86_64: size_t == vm_offset_t == unsigned long */
|
|
|
|
operator size_t () const { return sz; }
|
|
|
|
size_t operator = (size_t nsz) { return sz = nsz; }
|
|
|
|
#else
|
|
|
|
/* On i686: ssize_t == long == int */
|
|
|
|
operator ssize_t () const { return ssz; }
|
|
|
|
ssize_t operator = (ssize_t nssz) { return ssz = nssz; }
|
|
|
|
#endif
|
2003-10-22 18:07:59 +08:00
|
|
|
|
2003-11-20 02:50:23 +08:00
|
|
|
operator vm_offset_t () const { return off; }
|
|
|
|
vm_offset_t operator = (vm_offset_t noff) { return off = noff; }
|
2003-10-22 18:07:59 +08:00
|
|
|
|
2003-11-20 02:50:23 +08:00
|
|
|
operator vm_object_t () const { return obj; }
|
|
|
|
vm_object_t operator = (vm_object_t nobj) { return obj = nobj; }
|
|
|
|
};
|
2003-10-22 18:07:59 +08:00
|
|
|
|
2015-01-20 01:42:04 +08:00
|
|
|
class thread {
|
|
|
|
private:
|
|
|
|
/* Implemented in cgyserver/process.cc */
|
|
|
|
void dup_signal_arrived ();
|
|
|
|
void close_signal_arrived ();
|
|
|
|
public:
|
2003-11-20 02:50:23 +08:00
|
|
|
class process *client;
|
|
|
|
proc *ipcblk;
|
|
|
|
ipc_retval td_retval[2];
|
2015-01-20 01:42:04 +08:00
|
|
|
|
|
|
|
thread (class process *_client, proc *_proc, bool _init_m1)
|
|
|
|
: client (_client), ipcblk (_proc)
|
|
|
|
{
|
|
|
|
td_retval[0] = td_retval[1] = _init_m1 ? -1 : 0;
|
|
|
|
dup_signal_arrived ();
|
|
|
|
}
|
|
|
|
~thread () { close_signal_arrived (); }
|
2003-11-20 02:50:23 +08:00
|
|
|
};
|
|
|
|
#define td_proc ipcblk
|
|
|
|
#define p_pid cygpid
|
|
|
|
#endif
|
2003-10-22 18:07:59 +08:00
|
|
|
|
|
|
|
#endif /* __CYGSERVER_IPC_H__ */
|