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.
 | 
			
		||||
   Copyright (C) 1993 Free Software Foundation, Inc.
 | 
			
		||||
   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 | 
			
		||||
   Contributed by Brendan Kehoe (brendan@zen.org).
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
   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
 | 
			
		||||
to build the correct status return for things like waitpid */
 | 
			
		||||
 | 
			
		||||
/* These define the different states a child can have on exit.
 | 
			
		||||
   We need these to build the status return for things like waitpid.  */
 | 
			
		||||
#define EXITED 		1
 | 
			
		||||
#define KILLED		2
 | 
			
		||||
#define CORED		3
 | 
			
		||||
@@ -35,7 +34,7 @@ to build the correct status return for things like waitpid */
 | 
			
		||||
#define CONTINUED	6
 | 
			
		||||
 | 
			
		||||
typedef struct __siginfo
 | 
			
		||||
{
 | 
			
		||||
  {
 | 
			
		||||
    int filler1;
 | 
			
		||||
 | 
			
		||||
    /* Code indicating child's status */
 | 
			
		||||
@@ -53,7 +52,7 @@ typedef struct __siginfo
 | 
			
		||||
 | 
			
		||||
    int filler4[26];
 | 
			
		||||
 | 
			
		||||
} __siginfo_t;
 | 
			
		||||
  } __siginfo_t;
 | 
			
		||||
 | 
			
		||||
#endif  /* __USE_SVID */
 | 
			
		||||
#endif	/* siginfo.h */
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ Cambridge, MA 02139, USA.  */
 | 
			
		||||
#include "siginfo.h"
 | 
			
		||||
 | 
			
		||||
typedef enum __idtype
 | 
			
		||||
{
 | 
			
		||||
  {
 | 
			
		||||
    /* Look for processes based upon a given PID.  */
 | 
			
		||||
    P_PID,
 | 
			
		||||
 | 
			
		||||
@@ -33,7 +33,7 @@ typedef enum __idtype
 | 
			
		||||
 | 
			
		||||
    /* Look for any process.  */
 | 
			
		||||
    P_ALL = 7,
 | 
			
		||||
} __idtype_t;
 | 
			
		||||
  } __idtype_t;
 | 
			
		||||
 | 
			
		||||
extern __pid_t __getpgid __P ((__pid_t pid));
 | 
			
		||||
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.  */
 | 
			
		||||
 | 
			
		||||
__pid_t
 | 
			
		||||
DEFUN(__waitpid, (__pid, __stat_loc, __options),
 | 
			
		||||
      __pid_t __pid AND int *__stat_loc AND int __options)
 | 
			
		||||
DEFUN(__waitpid, (pid, stat_loc, options),
 | 
			
		||||
      __pid_t pid AND int *stat_loc AND int options)
 | 
			
		||||
{
 | 
			
		||||
  __idtype_t idtype;
 | 
			
		||||
  __pid_t tmp_pid = __pid;
 | 
			
		||||
  __pid_t tmp_pid = pid;
 | 
			
		||||
  __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.  */
 | 
			
		||||
	  idtype = P_ALL;
 | 
			
		||||
	}
 | 
			
		||||
      else if (__pid == WAIT_MYPGRP)
 | 
			
		||||
      else if (pid == WAIT_MYPGRP)
 | 
			
		||||
	{
 | 
			
		||||
	  /* Request the status for any child process that has
 | 
			
		||||
	     a pgid that's equal to that of our parent.  */
 | 
			
		||||
	  tmp_pid = __getpgid (0);
 | 
			
		||||
	  idtype = P_PGID;
 | 
			
		||||
	}
 | 
			
		||||
      else /* __pid < -1 */
 | 
			
		||||
      else /* PID < -1 */
 | 
			
		||||
	{
 | 
			
		||||
	  /* Request the status for any child whose pgid is equal
 | 
			
		||||
	     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;
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
@@ -88,13 +88,28 @@ DEFUN(__waitpid, (__pid, __stat_loc, __options),
 | 
			
		||||
      idtype = P_PID;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (__waitid (idtype, tmp_pid, &infop, __options | WEXITED | WTRAPPED) < 0)
 | 
			
		||||
    {
 | 
			
		||||
      *__stat_loc = infop.__status;
 | 
			
		||||
  if (__waitid (idtype, tmp_pid, &infop, options | WEXITED | WTRAPPED) < 0)
 | 
			
		||||
    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
 | 
			
		||||
     called with, to account for cases of being called with -1 to signify
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user