cff0b9e5ca
This tests repeatedly creates and kills children, so some corner cases in handling of not-quite-existing processes can be observed. Previously, strace was crashing in the following situation: 13994 ????( <unfinished ...> ... 13994 <... ???? resumed>) = ? as tcp->s_ent wasn't initialised on syscall entering and strace.c:print_event_exit segfaulted when tried to access tcp->s_ent->sys_name. * tests/kill_child.c: New file. * tests/kill_child.test: New test. * tests/Makefile.am (check_PROGRAMS): Add kill_child. (MISC_TESTS): Add kill_child.test.
47 lines
654 B
C
47 lines
654 B
C
/**
|
|
* Check for a corner case that previously lead to segfault due to an attempt
|
|
* to access unitialised tcp->s_ent.
|
|
*
|
|
* 13994 ????( <unfinished ...>
|
|
* ...
|
|
* 13994 <... ???? resumed>) = ?
|
|
*/
|
|
|
|
#include <signal.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
|
|
#include "tests.h"
|
|
|
|
#define ITERS 10000
|
|
#define SC_ITERS 10000
|
|
|
|
int main(void)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < ITERS; i++) {
|
|
int pid = fork();
|
|
|
|
if (pid < 0)
|
|
perror_msg_and_fail("fork");
|
|
|
|
if (!pid) {
|
|
unsigned int j;
|
|
|
|
for (j = 0; j < SC_ITERS; j++)
|
|
getuid();
|
|
|
|
pause();
|
|
|
|
return 0;
|
|
}
|
|
|
|
kill(pid, SIGKILL);
|
|
wait(NULL);
|
|
}
|
|
|
|
return 0;
|
|
}
|