🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #18767

Re: actived

#18767
From: Dan Foster
Date: Thu, 26 Jun 1997 00:00
69 lines
2737 bytes
>From: aos@insync.net
>Date: 25 Jun 1997 21:04:14 GMT
>Message-ID: <5os14e$c87$1@synthemesc.insync.net>
>References: <33A6B41D.3382@iconnet.net> <33A968C6.2C67@raleigh.ibm.com> 
><5oc0in$11p$1@earth.execpc.com> <33A98953.6EEA@raleigh.ibm.com> 
><5oeh5s$rgk$1@earth.execpc.com> <5opppm$i2p$1@news.wco.com> 
><5opspf$2mt$1@synthemesc.insync.net> <5oqdqa$opu$1@news.wco.com> 
><5orasp$900$2@synthemesc.insync.net> <33B14F18.7298@ais.net
>
>> fcntl(5, F_SETLK, 0xEFFFF284)                   Err#11 EAGAIN
>
>You haven't said what file is descriptor 5.  fcntl will get an EAGAIN if
>it tries to work on an already-locked file, so it would help if you could
>tell what file is open as number 5.  Methinks this might have something to
>do with my replacement of the daemon() call with a fork().
>
> Andrew Smith -- Sysadmin, Insync Internet Services |    PGP Fingerprint:

Out of curiosity... why change the daemon() to a fork()?

I couldn't compile it on my SysV box (AIX 4.1.4/4.2.1) so what I did was to
look in the BSD libc sources for daemon(), and it's pretty simple, looks
reasonably portable, and short.

So I copied'n'pasted the sources, and put it in daemon.c, and added daemon.c
and daemon.o to the Makefile. Worked out of the box with no further mods.

Here it is, from FreeBSD 2.2.2-RELEASE libc sources:

#include <fcntl.h>
#include <paths.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("/dev/null", 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);
}

-Dan Foster
Internet: dsf@frontiernet.net

Technical Details
Message-ID: <5ougjo$1g2u$1@node17.cwnet.frontiernet.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <5ougjo$1g2u$1@node17.cwnet.frontiernet.net>
Subject: Re: actived
Date: Thu, 26 Jun 1997 00:00:00 +0000
From: dsf@node6.frontiernet.net (Dan Foster)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 252789102
X-Trace: 867354040 49246 dsf@node6.frontiernet.net 205.232.174.25
Organization: Frontier Internet, A reliable part of your life
Newsgroups: news.software.nntp