File:
[DVB] /
dietlibc /
libcompat /
daemon.c
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Thu Feb 28 16:13:20 2002 UTC (22 years, 3 months ago) by
fefe
Branches:
MAIN
CVS tags:
finnland_test_200301,
branch_rc14_fieldtest_finnland,
branch_rc13_fieldtest_finnland,
branch_rc12_fieldtest_finnland,
branch_rc10_fieldtest_finnland,
RELEASE_finnland_200301_1,
RC12_FIELDTEST_FINNLAND,
RC10_FIELDTEST_FINNLAND,
HEAD
create libcompat (for future BSD and GNU extension crap we choose to
implement but don't want to blow up our stock libc)
Andre squeezed a few more bytes from the ARM assembly files
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <paths.h>
#include "daemon.h"
int daemon (int nochdir,int noclose)
{
int fd;
switch (fork()) {
case -1: return (-1);
case 0: break;
default: _exit (0);
}
if (setsid () == -1) return (-1);
if (!nochdir) chdir ("/");
if (!noclose) {
fd = open(_PATH_DEVNULL,O_RDWR,0);
if (fd == -1) return (-1);
dup2 (fd,STDIN_FILENO);
dup2 (fd,STDOUT_FILENO);
dup2 (fd,STDERR_FILENO);
if (fd>2) close (fd);
}
return (0);
}
LinuxTV legacy CVS <linuxtv.org/cvs>