Date: Mon, 27 Aug 2001 00:07:46 -0400 From: Josh M Osborne <stripes@iamsofired.com> To: hackers@FreeBSD.ORG Subject: Re: Proposed Utility - detach(1) Message-ID: <20010827000746.A17299@torb.pix.net> In-Reply-To: <20010826021029.B92887@dragon.nuxi.com>; from dev-null@NUXI.com on Sun, Aug 26, 2001 at 02:10:29AM -0700 References: <20010824141955.B64018@coffee.q9media.com> <20010826095321.A2037@laptop.6bone.nl> <20010826021029.B92887@dragon.nuxi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 26, 2001 at 02:10:29AM -0700, David O'Brien wrote: [...] > The BSD/OS 4.1 code is also available for us to take this utility from. Really? I didn't know they donated all of that. Anyway it isn't a complex program. When I migrated from BSD/OS to FreeBSD it is one of the things I missed, and wrote. Have it. Or write another. Or take BSD/OSes. #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int rc, ch, e; int noclose = 0, nochdir = 0; extern int optind, errno; char *pname = argv[0]; while((ch = getopt(argc, argv, "nr")) != -1) { switch(ch) { case 'n': noclose = 1; break; case 'r': nochdir = 1; break; case '?': default: fprintf(stderr, "Usage: %s [-c] [-r] command args...\n", pname); fprintf(stderr, " -n don't redirect std{in,out,err} to /dev/null\n"); fprintf(stderr, " -r don't chdir to / (root)\n"); exit(1); break; } } argc -= optind; argv += optind; printf("argc %d, argv[0] %s\n", argc, argv[0]); if (argc < 1) { fprintf(stderr, "%s: no command to run?\n", pname); exit(1); } rc = daemon(nochdir, noclose); if (rc < 0) { e = errno; fprintf(stderr, "%s: daemon call failed: %s\n", pname, strerror(e)); exit(2); } execvp(argv[0], argv); e = errno; /* This may be futile - stderr may be /dev/null */ fprintf(stderr, "%s: exec of %s failed: %s\n", pname, argv[0], strerror(e)); exit(3); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010827000746.A17299>