mirror of
https://sourceware.org/git/glibc.git
synced 2025-11-03 20:53:13 +03:00
entered into RCS
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* Definitions of the siginfo structure.
|
/* Definitions of the siginfo structure.
|
||||||
Copyright (C) 1993 Free Software Foundation, Inc.
|
Copyright (C) 1993, 1994 Free Software Foundation, Inc.
|
||||||
Contributed by Brendan Kehoe (brendan@zen.org).
|
Contributed by Brendan Kehoe (brendan@zen.org).
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -24,9 +24,8 @@ Cambridge, MA 02139, USA. */
|
|||||||
/* SVR4 puts a ton of other stuff in this structure. For now, we'll just
|
/* SVR4 puts a ton of other stuff in this structure. For now, we'll just
|
||||||
define the two things we really need out of it, and hope for the best. */
|
define the two things we really need out of it, and hope for the best. */
|
||||||
|
|
||||||
/* These define the different states a child can have on exit. Need these
|
/* These define the different states a child can have on exit.
|
||||||
to build the correct status return for things like waitpid */
|
We need these to build the status return for things like waitpid. */
|
||||||
|
|
||||||
#define EXITED 1
|
#define EXITED 1
|
||||||
#define KILLED 2
|
#define KILLED 2
|
||||||
#define CORED 3
|
#define CORED 3
|
||||||
@@ -35,25 +34,25 @@ to build the correct status return for things like waitpid */
|
|||||||
#define CONTINUED 6
|
#define CONTINUED 6
|
||||||
|
|
||||||
typedef struct __siginfo
|
typedef struct __siginfo
|
||||||
{
|
{
|
||||||
int filler1;
|
int filler1;
|
||||||
|
|
||||||
/* Code indicating child's status */
|
/* Code indicating child's status */
|
||||||
int __code;
|
int __code;
|
||||||
|
|
||||||
int filler2;
|
int filler2;
|
||||||
|
|
||||||
/* The PID of the child. */
|
/* The PID of the child. */
|
||||||
long __pid;
|
long __pid;
|
||||||
|
|
||||||
int filler3;
|
int filler3;
|
||||||
|
|
||||||
/* The child's status. */
|
/* The child's status. */
|
||||||
int __status;
|
int __status;
|
||||||
|
|
||||||
int filler4[26];
|
int filler4[26];
|
||||||
|
|
||||||
} __siginfo_t;
|
} __siginfo_t;
|
||||||
|
|
||||||
#endif /* __USE_SVID */
|
#endif /* __USE_SVID */
|
||||||
#endif /* siginfo.h */
|
#endif /* siginfo.h */
|
||||||
|
|||||||
@@ -24,16 +24,16 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include "siginfo.h"
|
#include "siginfo.h"
|
||||||
|
|
||||||
typedef enum __idtype
|
typedef enum __idtype
|
||||||
{
|
{
|
||||||
/* Look for processes based upon a given PID. */
|
/* Look for processes based upon a given PID. */
|
||||||
P_PID,
|
P_PID,
|
||||||
|
|
||||||
/* Look for processes based upon a given process-group ID. */
|
/* Look for processes based upon a given process-group ID. */
|
||||||
P_PGID = 2,
|
P_PGID = 2,
|
||||||
|
|
||||||
/* Look for any process. */
|
/* Look for any process. */
|
||||||
P_ALL = 7,
|
P_ALL = 7,
|
||||||
} __idtype_t;
|
} __idtype_t;
|
||||||
|
|
||||||
extern __pid_t __getpgid __P ((__pid_t pid));
|
extern __pid_t __getpgid __P ((__pid_t pid));
|
||||||
extern int __waitid __P ((__idtype_t idtype, __pid_t id,
|
extern int __waitid __P ((__idtype_t idtype, __pid_t id,
|
||||||
@@ -53,32 +53,32 @@ extern int __waitid __P ((__idtype_t idtype, __pid_t id,
|
|||||||
return status for stopped children; otherwise don't. */
|
return status for stopped children; otherwise don't. */
|
||||||
|
|
||||||
__pid_t
|
__pid_t
|
||||||
DEFUN(__waitpid, (__pid, __stat_loc, __options),
|
DEFUN(__waitpid, (pid, stat_loc, options),
|
||||||
__pid_t __pid AND int *__stat_loc AND int __options)
|
__pid_t pid AND int *stat_loc AND int options)
|
||||||
{
|
{
|
||||||
__idtype_t idtype;
|
__idtype_t idtype;
|
||||||
__pid_t tmp_pid = __pid;
|
__pid_t tmp_pid = pid;
|
||||||
__siginfo_t infop;
|
__siginfo_t infop;
|
||||||
|
|
||||||
if (__pid <= WAIT_MYPGRP)
|
if (pid <= WAIT_MYPGRP)
|
||||||
{
|
{
|
||||||
if (__pid == WAIT_ANY)
|
if (pid == WAIT_ANY)
|
||||||
{
|
{
|
||||||
/* Request the status for any child. */
|
/* Request the status for any child. */
|
||||||
idtype = P_ALL;
|
idtype = P_ALL;
|
||||||
}
|
}
|
||||||
else if (__pid == WAIT_MYPGRP)
|
else if (pid == WAIT_MYPGRP)
|
||||||
{
|
{
|
||||||
/* Request the status for any child process that has
|
/* Request the status for any child process that has
|
||||||
a pgid that's equal to that of our parent. */
|
a pgid that's equal to that of our parent. */
|
||||||
tmp_pid = __getpgid (0);
|
tmp_pid = __getpgid (0);
|
||||||
idtype = P_PGID;
|
idtype = P_PGID;
|
||||||
}
|
}
|
||||||
else /* __pid < -1 */
|
else /* PID < -1 */
|
||||||
{
|
{
|
||||||
/* Request the status for any child whose pgid is equal
|
/* Request the status for any child whose pgid is equal
|
||||||
to the absolute value of PID. */
|
to the absolute value of PID. */
|
||||||
tmp_pid = __pid & ~0; /* XXX not pseudo-insn */
|
tmp_pid = pid & ~0; /* XXX not pseudo-insn */
|
||||||
idtype = P_PGID;
|
idtype = P_PGID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,13 +88,28 @@ DEFUN(__waitpid, (__pid, __stat_loc, __options),
|
|||||||
idtype = P_PID;
|
idtype = P_PID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__waitid (idtype, tmp_pid, &infop, __options | WEXITED | WTRAPPED) < 0)
|
if (__waitid (idtype, tmp_pid, &infop, options | WEXITED | WTRAPPED) < 0)
|
||||||
{
|
return -1;
|
||||||
*__stat_loc = infop.__status;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*__stat_loc = infop.__status;
|
switch (infop.__code)
|
||||||
|
{
|
||||||
|
case EXITED:
|
||||||
|
*stat_loc = W_EXITCODE (infop.__status, 0);
|
||||||
|
break;
|
||||||
|
case STOPPED:
|
||||||
|
case TRAPPED:
|
||||||
|
*stat_loc = W_STOPCODE (infop.__status);
|
||||||
|
break;
|
||||||
|
case KILLED:
|
||||||
|
/* Don't know what to do with continue, since it isn't documented.
|
||||||
|
Putting it here seemed the right place though. */
|
||||||
|
case CONTINUED:
|
||||||
|
*stat_loc = infop.__status;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case CORED:
|
||||||
|
*stat_loc |= WCOREFLAG;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the PID out of the INFOP structure instead of the one we were
|
/* Return the PID out of the INFOP structure instead of the one we were
|
||||||
called with, to account for cases of being called with -1 to signify
|
called with, to account for cases of being called with -1 to signify
|
||||||
|
|||||||
Reference in New Issue
Block a user