Skip to content

Commit

Permalink
date and time created 90/06/15 14:47:14 by marc
Browse files Browse the repository at this point in the history
SCCS-vsn: lib/libc/gen/daemon.c 5.1
  • Loading branch information
Marc Teitelbaum authored and Marc Teitelbaum committed Jun 16, 1990
1 parent 91d68bd commit ec63289
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions usr/src/lib/libc/gen/daemon.c
@@ -0,0 +1,31 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* %sccs.include.redist.c%
*/

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)daemon.c 5.1 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */

#include <sys/file.h>

daemon()
{
int cpid;

if ((cpid = fork()) == -1)
return (-1);
if (cpid)
exit(0);

(void) setsid();
(void) chdir("/");
(void) close(0);
(void) close(1);
(void) close(2);
(void) open("/", O_RDONLY, 0);
(void) dup2(0, 1);
(void) dup2(0, 2);
}

0 comments on commit ec63289

Please sign in to comment.