Files
inetutils/libinetutils/daemon.c
Sergey Poznyakoff ce4e7a0f5a ftp/ChangeLog ftp/cmds.c ftp/cmdtab.c ftp/domacro.c
ftp/extern.h ftp/ftp.1 ftp/ftp.c ftp/ftp_var.h ftp/main.c
 	ftp/ruserpass.c ftpd/ChangeLog ftpd/extern.h ftpd/ftpcmd.y
 	ftpd/ftpd.8 ftpd/ftpd.c ftpd/popen.c headers/ChangeLog
 	headers/paths.h headers/syslog-int.h headers/tftpsubs.h
 	headers/arpa/ftp.h headers/arpa/telnet.h headers/arpa/tftp.h
 	headers/protocols/talkd.h inetd/ChangeLog inetd/inetd.8
 	inetd/inetd.c libinetutils/ChangeLog libinetutils/daemon.c
 	libinetutils/des_rw.c libinetutils/forkpty.c
 	libinetutils/iruserok.c libinetutils/kcmd.c
 	libinetutils/krcmd.c libinetutils/login_tty.c
 	libinetutils/openpty.c libinetutils/snprintf.c
 	libinetutils/snprintf.h libinetutils/syslog.c
 	libinetutils/tftpsubs.c libinetutils/ttymsg.c
 	libinetutils/utmp_init.c libls/cmp.c libls/extern.h libls/ls.1
 	libls/ls.c libls/ls.h libls/print.c libls/stat_flags.c
 	libls/util.c libtelnet/ChangeLog libtelnet/auth-proto.h
 	libtelnet/auth.c libtelnet/auth.h libtelnet/enc-proto.h
 	libtelnet/enc_des.c libtelnet/encrypt.c libtelnet/encrypt.h
 	libtelnet/forward.c libtelnet/genget.c libtelnet/getent.c
 	libtelnet/kerberos.c libtelnet/kerberos5.c
 	libtelnet/key-proto.h libtelnet/misc-proto.h libtelnet/misc.c
 	libtelnet/misc.h libtelnet/read_passwd.c rcp/ChangeLog
 	rcp/extern.h rcp/rcp.1 rcp/rcp.c rcp/util.c rexecd/ChangeLog
 	rexecd/rexecd.8 rexecd/rexecd.c rlogin/ChangeLog
 	rlogin/rlogin.1 rlogin/rlogin.c rlogind/ChangeLog
 	rlogind/rlogind.8 rlogind/rlogind.c rsh/ChangeLog rsh/rsh.1
 	rsh/rsh.c rshd/ChangeLog rshd/rshd.8 rshd/rshd.c
 	syslog/ChangeLog syslog/syslog.1 syslog/syslog.c
 	syslogd/ChangeLog syslogd/syslog.conf.5 syslogd/syslogd.8
 	syslogd/syslogd.c talk/ChangeLog talk/ctl.c
 	talk/ctl_transact.c talk/display.c talk/get_addrs.c
 	talk/get_names.c talk/init_disp.c talk/invite.c talk/io.c
 	talk/look_up.c talk/msgs.c talk/talk.1 talk/talk.c talk/talk.h
 	talk/talk_ctl.h talkd/ChangeLog talkd/announce.c talkd/print.c
 	talkd/process.c talkd/table.c talkd/talkd.8 talkd/talkd.c
 	telnet/ChangeLog telnet/authenc.c telnet/commands.c
 	telnet/defines.h telnet/externs.h telnet/fdset.h
 	telnet/general.h telnet/main.c telnet/network.c telnet/ring.c
 	telnet/ring.h telnet/sys_bsd.c telnet/telnet.1 telnet/telnet.c
 	telnet/terminal.c telnet/tn3270.c telnet/types.h
 	telnet/utilities.c telnetd/ChangeLog telnetd/authenc.c
 	telnetd/defs.h telnetd/ext.h telnetd/global.c telnetd/slc.c
 	telnetd/state.c telnetd/sys_term.c telnetd/telnetd.8
 	telnetd/telnetd.c telnetd/telnetd.h telnetd/termstat.c
 	telnetd/utility.c tftp/ChangeLog tftp/extern.h tftp/main.c
 	tftp/tftp.1 tftp/tftp.c tftpd/ChangeLog tftpd/tftpd.8
 	tftpd/tftpd.c uucpd/ChangeLog uucpd/uucpd.c whois/ChangeLog
 	whois/main.c whois/net.c

	* *: Clause 3 removed.
	excerpt from email with RMS:
	"UCB has agreed to drop the advertising clause from the license for all
	BSD software.  The advertising clause is this one:

	3. All advertising materials mentioning features or use of this software
		must display the following acknowledgement:
		This product includes software developed by the University of
		California, Berkeley and its contributors.

	This means that we can delete that paragraph from all files which give
	the University of California as the only copyright holder."
2000-07-06 04:21:09 +00:00

68 lines
2.2 KiB
C

/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <config.h>
#include <fcntl.h>
#include <unistd.h>
int
daemon(nochdir, noclose)
int nochdir, noclose;
{
int fd;
switch (fork()) {
case -1:
return (-1);
case 0:
break;
default:
_exit(0);
}
if (setsid() == -1)
return (-1);
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = open(PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
if (fd > 2)
(void)close (fd);
}
return (0);
}