waitdbg

SIGSTOP programs at start for debugging
git clone https://git.sinitax.com/sinitax/waitdbg
Log | Files | Refs | LICENSE | sfeed.txt

waitdbg.c (436B)


      1#include <unistd.h>
      2#include <signal.h>
      3#include <errno.h>
      4#include <string.h>
      5#include <stdio.h>
      6#include <stdlib.h>
      7
      8int
      9main(int argc, const char **argv)
     10{
     11	if (argc < 2) {
     12		fprintf(stderr, "Usage: waitdbg CMD [ARG]..\n");
     13		return 0;
     14	}
     15
     16	fprintf(stderr, "waitdbg: pid %u (%s)\n", getpid(), argv[1]);
     17
     18	raise(SIGSTOP);
     19
     20	execvp(argv[1], (void *) &argv[1]);
     21
     22	fprintf(stderr, "waitdbg: execv %s: %s",
     23		argv[1], strerror(errno));
     24}