newlib/winsup/cygwin/include/sys/cygwin.h
Christopher Faylor 84c7d40932 * include/cygwin/version.h: Bump DLL minor version number to 5 due to all of
the changes below.  Redefine process structure to avoid a fixed size table.
Redefine pinfo/_pinfo classes.  Use these throughout.
* dcrt0.cc (dll_crt0_1): Accomodate set_myself argument change.
(__api_fatal): Accomodate _pinfo::record_death argument change.
* exceptions.cc (really_exit): Ditto.
(sig_handle_tty_stop): Use pinfo constructor to access process info.
(events_init): Don't create pinfo_mutex since it is no longer required.
* external.cc (fillout_pinfo): Use winpids class to iterate over all system
pids.
(cygwin_internal): lock_pinfo_for_update and unlock_pinfo are now noops.
* fhandler_termios.cc (fhandler_termios::set_ctty): Use pinfo constructor to
access process info.
* fork.cc (fork): Reorganize to initialize child info after the child has
started since that is when we know the child's winpid, which is necessary to
allocate the pinfo shared memory.
* mmap.cc (recreate_mmaps_after_fork): Change arg type to _pinfo.
* pinfo.cc: Rename pinfo methods to _pinfo throughout.  Eliminate pinfo_list
stuff.
(set_myself): Accept a pid argument now.  Call pinfo initializer to initialize
myself.  Detect when this is an "execed" process and create an "indirect" pid
block.
(pinfo_init): Accomodate set_myself arg change.
(procinfo): Remove.
(pinfo::lock_pinfo): Remove.
(pinfo::unlock_pinfo): Remove.
(pinfo::init): New method.  Allocates shared memory space for process pinfo
structure.
(pinfo::record_death): Don't call locking functions.
(cygwin_winpid_to_pid): Simplify by using new pinfo constructor.
(EnumProcessesW95): New function for iterating over processes on Windows 95.
(winpids::winpids): New constructor for winpids class.  Sets up a list of
process ids.
(enum_init): Initialize w95/wnt pid enumerators.
* shared.cc (shared-info::initialize): Remove pid initialization.
* shared.h: Move pinfo stuff into pinfo.h.
(class shared_info): Remove pinfo_list element.
* signal.cc (kill_worker): Use pinfo constructor to access process info.
(kill_pgrp): Ditto.  Use winpids methods to access list of processes.
* sigproc.cc: Throughout, modify to use _pinfo where appropriate.
(proc_exists (pid_t)): New function.  Determines if a process exists based on
the pid.
(proc_exists (_pinfo *p): Use new proc_exists function above.
(proc_subproc): Copy pinfo stuff around rather than _pinfo pointers.  Try to be
careful about releasing shared memory when we don't need it anymore.  Remove
pinfo locks.
(remove_zombies): Remove pinfo memory when zombie is going away.
* sigproc.h: Reflect _pinfo/pinfo changes in sigproc.cc.
* spawn.cc (spawn_guts): Eliminate pinfo *child argument.  Reorganize to only
initialize child pinfo after process has been started and we know the windows
pid.
(_spawnve): Reflect spawn_guts changes.
* syscalls.cc (setpgid): Use pinfo constructor to access process info.
(getpgid): Ditto.
(internal_getlogin): Use _pinfo.
* winsup.h: Eliminate pinfo_mutex.  Eliminate spawn_guts declaration since it
is static now.  Reflect set_myself argument change.
* include/sys/cygwin.h: Add some PID_* enums to accomodate new pinfo stuff.
* include/cygwin/version.h: Update minor version for cygdrive changes below.
2000-07-29 16:24:59 +00:00

227 lines
7.0 KiB
C

#ifndef _SYS_CYGWIN_H
#define _SYS_CYGWIN_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
extern pid_t cygwin32_winpid_to_pid (int);
extern void cygwin32_win32_to_posix_path_list (const char *, char *);
extern int cygwin32_win32_to_posix_path_list_buf_size (const char *);
extern void cygwin32_posix_to_win32_path_list (const char *, char *);
extern int cygwin32_posix_to_win32_path_list_buf_size (const char *);
extern int cygwin32_conv_to_win32_path (const char *, char *);
extern int cygwin32_conv_to_full_win32_path (const char *, char *);
extern void cygwin32_conv_to_posix_path (const char *, char *);
extern void cygwin32_conv_to_full_posix_path (const char *, char *);
extern int cygwin32_posix_path_list_p (const char *);
extern void cygwin32_split_path (const char *, char *, char *);
extern pid_t cygwin_winpid_to_pid (int);
extern int cygwin_win32_to_posix_path_list (const char *, char *);
extern int cygwin_win32_to_posix_path_list_buf_size (const char *);
extern int cygwin_posix_to_win32_path_list (const char *, char *);
extern int cygwin_posix_to_win32_path_list_buf_size (const char *);
extern int cygwin_conv_to_win32_path (const char *, char *);
extern int cygwin_conv_to_full_win32_path (const char *, char *);
extern int cygwin_conv_to_posix_path (const char *, char *);
extern int cygwin_conv_to_full_posix_path (const char *, char *);
extern int cygwin_posix_path_list_p (const char *);
extern void cygwin_split_path (const char *, char *, char *);
extern void cygwin_premain0 (int argc, char **argv);
extern void cygwin_premain1 (int argc, char **argv);
extern void cygwin_premain2 (int argc, char **argv);
extern void cygwin_premain3 (int argc, char **argv);
struct __cygwin_perfile
{
char *name;
unsigned flags;
};
#ifdef _PATH_PASSWD
extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
#endif
/* External interface stuff */
typedef enum
{
CW_LOCK_PINFO,
CW_UNLOCK_PINFO,
CW_GETTHREADNAME,
CW_GETPINFO,
CW_SETPINFO,
CW_SETTHREADNAME,
CW_GETVERSIONINFO,
CW_READ_V1_MOUNT_TABLES,
CW_USER_DATA,
CW_PERFILE,
CW_GET_CYGDRIVE_PREFIXES,
CW_GETPINFO_FULL
} cygwin_getinfo_types;
#define CW_NEXTPID 0x80000000 // or with pid to get next one
/* Flags associated with process_state */
enum
{
PID_NOT_IN_USE = 0x0000, // Free entry.
PID_IN_USE = 0x0001, // Entry in use.
PID_ZOMBIE = 0x0002, // Child exited: no parent wait.
PID_STOPPED = 0x0004, // Waiting for SIGCONT.
PID_TTYIN = 0x0008, // Waiting for terminal input.
PID_TTYOU = 0x0010, // Waiting for terminal output.
PID_ORPHANED = 0x0020, // Member of an orphaned process group.
PID_ACTIVE = 0x0040, // Pid accepts signals.
PID_CYGPARENT = 0x0080, // Set if parent was a cygwin app.
PID_SPLIT_HEAP = 0x0100, // Set if the heap has been split,
// which means we can't fork again.
PID_CLEAR = 0x0200, // Flag that pid should be cleared from parent's
// wait list
PID_SOCKETS_USED = 0x0400, // Set if process uses Winsock.
PID_INITIALIZING = 0x0800, // Set until ready to receive signals.
PID_USETTY = 0x1000, // Setting this enables or disables cygwin's
// tty support. This is inherited by
// all execed or forked processes.
PID_REPARENT = 0x2000, // child has execed
PID_EXECED = 0x4000, // redirect to original pid info block
PID_NOREDIR = 0x8000 // don't redirect if execed
};
#ifdef WINVER
/* This lives in the app and is initialized before jumping into the DLL.
It should only contain stuff which the user's process needs to see, or
which is needed before the user pointer is initialized, or is needed to
carry inheritance information from parent to child. Note that it cannot
be used to carry inheritance information across exec!
Remember, this structure is linked into the application's executable.
Changes to this can invalidate existing executables, so we go to extra
lengths to avoid having to do it.
When adding/deleting members, remember to adjust {public,internal}_reserved.
The size of the class shouldn't change [unless you really are prepared to
invalidate all existing executables]. The program does a check (using
SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
*/
struct per_process
{
char *initial_sp;
/* The offset of these 3 values can never change. */
/* magic_biscuit is the size of this class and should never change. */
unsigned long magic_biscuit;
unsigned long dll_major;
unsigned long dll_minor;
struct _reent **impure_ptr_ptr;
char ***envptr;
/* Used to point to the memory machine we should use. Usually these
point back into the dll, but they can be overridden by the user. */
void *(*malloc)(size_t);
void (*free)(void *);
void *(*realloc)(void *, size_t);
int *fmode_ptr;
int (*main)(int, char **, char **);
void (**ctors)(void);
void (**dtors)(void);
/* For fork */
void *data_start;
void *data_end;
void *bss_start;
void *bss_end;
void *(*calloc)(size_t, size_t);
/* For future expansion of values set by the app. */
void (*premain[4]) (int, char **);
/* The rest are *internal* to cygwin.dll.
Those that are here because we want the child to inherit the value from
the parent (which happens when bss is copied) are marked as such. */
/* non-zero of ctors have been run. Inherited from parent. */
int run_ctors_p;
DWORD unused[3];
/* Heap management. Inherited from parent. */
void *heapbase; /* bottom of the heap */
void *heapptr; /* current index into heap */
void *heaptop; /* current top of heap */
DWORD unused1; /* unused */
/* Non-zero means the task was forked. The value is the pid.
Inherited from parent. */
int forkee;
HMODULE hmodule;
DWORD api_major; /* API version that this program was */
DWORD api_minor; /* linked with */
/* For future expansion, so apps won't have to be relinked if we
add an item. */
DWORD unused2[5];
#ifdef __INSIDE_CYGWIN__
ResourceLocks *resourcelocks;
MTinterface *threadinterface;
#else
void *resourcelocks;
void *threadinterface;
#endif
struct _reent *impure_ptr;
};
#define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->resourcelocks))
extern void cygwin_set_impersonation_token (const HANDLE);
/* included if <windows.h> is included */
extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
#include <sys/resource.h>
struct external_pinfo
{
pid_t pid;
pid_t ppid;
HANDLE hProcess;
DWORD dwProcessId, dwSpawnedProcessId;
uid_t uid;
gid_t gid;
pid_t pgid;
pid_t sid;
int ctty;
mode_t umask;
long start_time;
struct rusage rusage_self;
struct rusage rusage_children;
char progname[MAX_PATH];
DWORD strace_mask;
HANDLE strace_file;
DWORD process_state;
};
DWORD cygwin_internal (cygwin_getinfo_types, ...);
#endif /*WINVER*/
#ifdef __cplusplus
};
#endif
#endif /* _SYS_CYGWIN_H */