sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 0df09d5ba02a46b3886989f11dac060fb53ba619
parent 991ff9006421d80e42bc974a1cdc5a352f73f18b
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 14 Jul 2020 10:15:43 +0200

setsid: add optional -f to force fork()

Diffstat:
Msetsid.1 | 3++-
Msetsid.c | 9+++++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/setsid.1 b/setsid.1 @@ -1,4 +1,4 @@ -.Dd 2015-10-08 +.Dd 2020-07-14 .Dt SETSID 1 .Os sbase .Sh NAME @@ -6,6 +6,7 @@ .Nd run a command in a new session .Sh SYNOPSIS .Nm +.Op Fl f .Ar cmd .Op Ar arg ... .Sh DESCRIPTION diff --git a/setsid.c b/setsid.c @@ -4,10 +4,12 @@ #include "util.h" +static int fflag = 0; + static void usage(void) { - eprintf("usage: %s cmd [arg ...]\n", argv0); + eprintf("usage: %s cmd [-f] [arg ...]\n", argv0); } int @@ -16,6 +18,9 @@ main(int argc, char *argv[]) int savederrno; ARGBEGIN { + case 'f': + fflag = 1; + break; default: usage(); } ARGEND @@ -23,7 +28,7 @@ main(int argc, char *argv[]) if (!argc) usage(); - if (getpgrp() == getpid()) { + if (fflag || getpgrp() == getpid()) { switch (fork()) { case -1: eprintf("fork:");