* strace.cc (proc_child): Propagate return code from child process.

(dostrace): Ditto.
(main): Ditto.
This commit is contained in:
Christopher Faylor 2006-05-24 16:50:50 +00:00
parent 89af1688ef
commit 6265ac10be
2 changed files with 16 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2006-05-24 Christopher Faylor <cgf@timesys.com>
* strace.cc (proc_child): Propagate return code from child process.
(dostrace): Ditto.
(main): Ditto.
2006-03-03 Christian Franke <franke@computer.org> 2006-03-03 Christian Franke <franke@computer.org>
* regtool.cc (options): Add 'binary'. * regtool.cc (options): Add 'binary'.

View File

@ -588,9 +588,10 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
fflush (ofile); fflush (ofile);
} }
static void static DWORD
proc_child (unsigned mask, FILE *ofile, pid_t pid) proc_child (unsigned mask, FILE *ofile, pid_t pid)
{ {
DWORD res = 0;
DEBUG_EVENT ev; DEBUG_EVENT ev;
time_t cur_time, last_time; time_t cur_time, last_time;
@ -640,6 +641,7 @@ proc_child (unsigned mask, FILE *ofile, pid_t pid)
break; break;
case EXIT_PROCESS_DEBUG_EVENT: case EXIT_PROCESS_DEBUG_EVENT:
res = ev.u.ExitProcess.dwExitCode >> 8;
remove_child (ev.dwProcessId); remove_child (ev.dwProcessId);
break; break;
case EXCEPTION_DEBUG_EVENT: case EXCEPTION_DEBUG_EVENT:
@ -659,6 +661,8 @@ proc_child (unsigned mask, FILE *ofile, pid_t pid)
if (!processes) if (!processes)
break; break;
} }
return res;
} }
static void static void
@ -676,16 +680,15 @@ dotoggle (pid_t pid)
return; return;
} }
static void static DWORD
dostrace (unsigned mask, FILE *ofile, pid_t pid, char **argv) dostrace (unsigned mask, FILE *ofile, pid_t pid, char **argv)
{ {
if (!pid) if (!pid)
create_child (argv); create_child (argv);
else else
attach_process (pid); attach_process (pid);
proc_child (mask, ofile, pid);
return; return proc_child (mask, ofile, pid);
} }
typedef struct tag_mask_mnemonic typedef struct tag_mask_mnemonic
@ -1035,10 +1038,12 @@ character #%d.\n", optarg, (int) (endptr - optarg), endptr);
if (!ofile) if (!ofile)
ofile = stdout; ofile = stdout;
DWORD res = 0;
if (toggle) if (toggle)
dotoggle (pid); dotoggle (pid);
else else
dostrace (mask, ofile, pid, argv + optind); res = dostrace (mask, ofile, pid, argv + optind);
return res;
} }
#undef CloseHandle #undef CloseHandle