diff --git a/src/main.c b/src/main.c index 979fe0c..8d02704 100644 --- a/src/main.c +++ b/src/main.c @@ -163,6 +163,15 @@ int main(int argc, char **argv) /* and drop said privileges */ osDropPriv(); + /* we want to be the leader of a single process group, to make + * cleanup easier */ + if (getpgid(getpid()) != getpid()) { + if (setsid() != getpid()) { + fprintf(stderr, "could not create session\n"); + return 1; + } + } + /* we default to name being hostname, so get it*/ if (gethostname(hostname, _POSIX_HOST_NAME_MAX - 1) == -1) { perror("gethostname");