[Patch]Fix the output of argument "options" for wait4, waitpid and waitid
Cai Fei
caifei@cn.fujitsu.com
Thu Aug 23 17:50:00 GMT 2007
Hi, all
The system calls wait4, waitpid and waitid has an argument "int options".
About the value of it, wait and waitpid's part in man page is:
--------------------------------------
The value of options is an OR of zero or more of the following
constants:
WNOHANG
WUNTRACED
WCONTINUED
--------------------------------------
and waitid's part is:
--------------------------------------
The child state changes to wait for are specified by ORing one or
more of the following flags in options:
WEXITED
WSTOPPED
WCONTINUED
WNOHANG
WNOWAIT
--------------------------------------
and the values of WSTOPPED and WUNTRACED are equal.
In aux_syscalls.stp, the function _wait4_opt_str is used for printing
the flag string of options of all the 3 system calls(wait4, waitpid and
waitid). I think it is not proper to deal with the 3 system calls in the
same way, So I modified the function _wait4_opt_str for wait4 and waitpid,
and added a function _waitid_opt_str for waitid.
Here is the patch:
diff -Nur systemtap-20070818/tapset/aux_syscalls.stp systemtap-20070818new/tapset/aux_syscalls.stp
--- systemtap-20070818/tapset/aux_syscalls.stp 2007-08-16 22:12:07.000000000 +0900
+++ systemtap-20070818new/tapset/aux_syscalls.stp 2007-08-22 17:02:03.000000000 +0900
@@ -1071,6 +1071,14 @@
/* `man wait4` for more information */
function _wait4_opt_str(f) {
+ if(f & 8) bs="WCONTINUED|".bs
+ if(f & 2) bs="WUNTRACED|".bs
+ if(f & 1) bs="WNOHANG|".bs
+ return substr(bs,0,strlen(bs)-1)
+}
+
+/* `man waitid` for more information */
+function _waitid_opt_str(f) {
if(f & 0x01000000) bs="WNOWAIT|".bs
if(f & 8) bs="WCONTINUED|".bs
if(f & 4) bs="WEXITED|".bs
diff -Nur systemtap-20070818/tapset/syscalls2.stp systemtap-20070818new/tapset/syscalls2.stp
--- systemtap-20070818/tapset/syscalls2.stp 2007-08-16 04:17:35.000000000 +0900
+++ systemtap-20070818new/tapset/syscalls2.stp 2007-08-22 17:02:37.000000000 +0900
@@ -2869,7 +2869,7 @@
pid = $pid
infop_uaddr = $infop
options = $options
- options_str = _wait4_opt_str($options)
+ options_str = _waitid_opt_str($options)
rusage_uaddr = $ru
argstr = sprintf("%d, %d, %p, %s, %p", $which, $pid,
infop_uaddr, options_str, rusage_uaddr)
Regards, Cai Fei
More information about the Systemtap
mailing list