6 # define __WNOTHREAD 0x20000000
9 # define __WALL 0x40000000
12 # define __WCLONE 0x80000000
15 #include "xlat/wait4_options.h"
17 #if !defined WCOREFLAG && defined WCOREFLG
18 # define WCOREFLAG WCOREFLG
21 # define WCOREFLAG 0x80
24 # define WCOREDUMP(status) ((status) & 0200)
27 # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
30 # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
34 printstatus(int status)
39 * Here is a tricky presentation problem. This solution
40 * is still not entirely satisfactory but since there
41 * are no wait status constructors it will have to do.
43 if (WIFSTOPPED(status)) {
44 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
45 signame(WSTOPSIG(status)));
46 status &= ~W_STOPCODE(WSTOPSIG(status));
48 else if (WIFSIGNALED(status)) {
49 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
50 signame(WTERMSIG(status)),
51 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
52 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
54 else if (WIFEXITED(status)) {
55 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
58 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
61 tprintf("[%#x]", status);
68 tprintf(" | %#x]", status);
74 printwaitn(struct tcb *tcp, int n, int bitness)
79 /* On Linux, kernel-side pid_t is typedef'ed to int
80 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
81 * pid argument to int on 64bit arches, producing,
82 * for example, wait4(4294967295, ...) instead of -1
83 * in strace. We have to use int here, not long.
85 int pid = tcp->u_arg[0];
91 else if (syserror(tcp) || tcp->u_rval == 0)
92 tprintf("%#lx", tcp->u_arg[1]);
93 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
99 printflags(wait4_options, tcp->u_arg[2], "W???");
105 else if (tcp->u_rval > 0) {
108 printrusage32(tcp, tcp->u_arg[3]);
111 printrusage(tcp, tcp->u_arg[3]);
114 tprintf("%#lx", tcp->u_arg[3]);
121 sys_waitpid(struct tcb *tcp)
123 return printwaitn(tcp, 3, 0);
127 sys_wait4(struct tcb *tcp)
129 return printwaitn(tcp, 4, 0);
134 sys_osf_wait4(struct tcb *tcp)
136 return printwaitn(tcp, 4, 1);
140 #include "xlat/waitid_types.h"
143 sys_waitid(struct tcb *tcp)
146 printxval(waitid_types, tcp->u_arg[0], "P_???");
147 tprintf(", %ld, ", tcp->u_arg[1]);
151 printsiginfo_at(tcp, tcp->u_arg[2]);
154 printflags(wait4_options, tcp->u_arg[3], "W???");
155 if (tcp->s_ent->nargs > 4) {
160 else if (tcp->u_error)
161 tprintf("%#lx", tcp->u_arg[4]);
163 printrusage(tcp, tcp->u_arg[4]);