CVS Commit of 'strace ChangeLog'
Ganesan Rajagopal
rganesan at myrealbox.com
Mon Mar 19 11:10:23 UTC 2001
Wichert,
Can you include, the following patch that I sent earlier for tracing
(sortof) multi-threaded programs.
Index: strace.c
===================================================================
RCS file: /cvsroot/strace/strace/strace.c,v
retrieving revision 1.20
diff -u -r1.20 strace.c
--- strace.c 2000/09/03 23:57:48 1.20
+++ strace.c 2001/01/03 08:45:51
@@ -1586,6 +1586,15 @@
#else /* !USE_PROCFS */
+#ifdef LINUX
+#ifndef __WCLONE
+#define __WCLONE 0x8000000
+#endif
+#ifndef __WALL
+#define __WALL 0x4000000
+#endif
+#endif /* LINUX */
+
static int
trace()
{
@@ -1594,6 +1603,8 @@
int status;
struct tcb *tcp;
#ifdef LINUX
+ /* __WALL is only supported by 2.4 kernels */
+ static int wait4_options = __WALL;
struct rusage ru;
#endif /* LINUX */
@@ -1601,7 +1612,26 @@
if (interactive)
sigprocmask(SIG_SETMASK, &empty_set, NULL);
#ifdef LINUX
- pid = wait4(-1, &status, 0, cflag ? &ru : NULL);
+ pid = wait4(-1, &status, wait4_options, cflag ? &ru : NULL);
+ if ((wait4_options & __WALL) && errno == EINVAL) {
+ /* this kernel does not support __WALL */
+ wait4_options &= ~__WALL;
+ errno = 0;
+ pid = wait4(-1, &status, wait4_options,
+ cflag ? &ru : NULL);
+ }
+ if (!(wait4_options & _WALL) && errno == ECHILD) {
+ /* most likely a "cloned" process */
+ pid = wait4(-1, &status, __WCLONE,
+ cflag ? &ru : NULL);
+ if (pid == -1) {
+ fprintf(stderr, "strace: clone wait4 "
+ "failed: %s\n", strerror(errno));
+ }
+ }
+
+
+
#endif /* LINUX */
#ifdef SUNOS4
pid = wait(&status);
--
R. Ganesan (rganesan at novell.com) | Ph: 91-80-5731856 Ext: 2149
Novell India Development Center. | #include <std_disclaimer.h>
More information about the Strace-devel
mailing list