#include <assert.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <linux/unistd.h>
+#include <unistd.h>
#include <limits.h>
#include <string.h>
#include <pthread.h>
+#include <sys/syscall.h>
#include "debugger.h"
#include "debugger.c"
-_syscall2(int, tkill, int, tid, int, sig)
-int tkill(int tid, int sig);
+#define tkill(tid, sig) syscall (SYS_tkill, (tid), (sig))
static int attach_checked (pid_t pid, int redelivered_expect)
struct registry *iter;
for (iter = registry_list; iter != NULL; iter = iter->next)
- kill (iter->pid, SIGKILL);
+ {
+ tkill (iter->pid, SIGCONT);
+ tkill (iter->pid, SIGKILL);
+ kill (iter->pid, SIGKILL);
+ }
}
static void registry_cleanup (void)
if (!(pid_got == -1 && errno == ECHILD))
{
assert (pid_got == pid);
- assert ((WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL)
+ assert ((WIFSIGNALED (status) && (WTERMSIG (status) == SIGKILL
+ || WTERMSIG (status) == SIGUSR2))
|| (WIFEXITED (status) && WEXITSTATUS (status) == 0));
STATE (pid, 1 << STATE_ENOENT);
}
delay ();
i = tkill (inferior, SIGCONT);
assert (i == 0);
- /* This is a race, we may not prove the successful SIGALRM delivery by it. */
+ /* This is a race, we may not prove the successful SIGALRM delivery by it.
+ Rather recheck it below. */
STATE (inferior, 1 << STATE_RUNNING);
- murder (inferior);
+ delay ();
+ i = tkill (inferior, SIGSTOP);
+ assert (i == 0);
+ /* Wait till it gets stopped otherwise we may get STATE_ENOENT below. */
+ STATE (inferior, 1 << STATE_STOPPED);
+ delay ();
+ i = tkill (inferior, SIGUSR2);
+ assert (i == 0);
+ STATE (inferior, 1 << STATE_STOPPED);
+ delay ();
+ i = tkill (inferior, SIGCONT);
+ assert (i == 0);
+ /* Not just STATE_ZOMBIE as we can get spawn with waiter. FIXME. */
+ STATE (inferior, (1 << STATE_ENOENT) | (1 << STATE_ZOMBIE) | (1 << STATE_DEAD));
+ /* We would fail on: murder (inferior); */
}
static void *pass (void *data, void *input)
int loop = 0;
int i;
+#ifdef MEASURE_STATE_PERFORMANCE
+ STATE (1, 1 << STATE_ZOMBIE);
+ return 0;
+#endif /* MEASURE_STATE_PERFORMANCE */
+
if (argc == 1)
;
else if (argc == 2 && strcmp (argv[1], "-l") == 0)