File: waitid.c

package info (click to toggle)
glibc 2.31-13%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 278,368 kB
  • sloc: ansic: 1,025,361; asm: 256,790; makefile: 12,097; sh: 10,548; python: 9,618; cpp: 5,233; awk: 1,956; perl: 514; yacc: 290; pascal: 182; sed: 73
file content (108 lines) | stat: -rw-r--r-- 2,642 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* 
   Copyright (C) 2004-2012 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#include <shlib-compat.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
#include <sysdep.h>

extern int __syscall_wait6 (idtype_t itype, int64_t id,
			    int *status, int options,
			    struct rusage *rusage, siginfo_t *infop);
libc_hidden_proto (__syscall_wait6)


#define DO_WAITID simulated_waitid
static int simulated_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options);


#if !defined __ASSUME_WAIT6
static int __have_wait6;
#endif

static inline int
do_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
{
  int ret;
  int status;
#ifndef __ASSUME_WAIT6
  if (__have_wait6 >= 0)
#endif
  {
      ret = INLINE_SYSCALL (wait6, 6, idtype, id, &status, options, NULL, infop);
      
      if (ret == 0 && infop != NULL)
      {
          memset(infop, 0, sizeof(*infop));
      }
      if (ret >= 0)
          return 0;
#ifndef __ASSUME_WAIT6
      if (errno == ENOSYS)
      {
          __have_wait6 = -1;
      }
      else
#endif
      {
          return ret;
      }
   }
   return simulated_waitid(idtype, id, infop, options);
}

 
#define waitid __unused_waitid_alias
#include <sysdeps/posix/waitid.c>
#undef waitid

versioned_symbol (libc, __waitid, waitid, GLIBC_2_18);

#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_18)

/* it used to be: */

#define OLD_P_ALL	0
#define OLD_P_PID	1
#define OLD_P_PGID	2

int
__waitid_old (idtype_t oldtype, id_t id, siginfo_t *infop, int options)
{
  idtype_t newtype;

  switch (oldtype)
  {
      case OLD_P_ALL:
          newtype = P_ALL;
      break;
      case OLD_P_PID:
          newtype = P_PID;
      break;
      case OLD_P_PGID:
          newtype = P_PGID;
      break;
      default:
          newtype = oldtype;
   }
  return __waitid(newtype, id, infop, options);
}
compat_symbol (libc, __waitid_old, waitid, GLIBC_2_1);
#endif