🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.os.linux.programowanie
Article #71305

Re: daemon - przyklady

#71305
From: Michoo
Date: Sun, 11 Oct 2009 10:27
32 lines
1356 bytes
Seweryn Habdank-Wojewódzki pisze:
> Witam,
> 
> Szukam przykladu uzycia funcji
> 
> int daemon(int, int)
> 
> z <unistd.h>.
> 
> Czy ktos wie gdzie moge znalezc takowy?
Żartujesz,prawda?


Prawie każdy daemon tego używa. Reszta pisze to po swojemu:
int r=fork();
if(r==0)
{
   close(0);
   close(1);
   close(2);
   open("/dev/null/",O_RDONLY);
   open("/dev/null/",O_WRONLY);
   open("/dev/null/",O_WRONLY);
}
else if(r==-1)
	;//błąd
else
     _exit();

-- 
Pozdrawiam
Michoo
Technical Details
Message-ID: <hasbt8$l97$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail
References: <f7af2e8a-0a9e-4678-94ef-5aaf5c72a3ff@y21g2000yqn.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail
From: Michoo <michoo_news@vp.pl>
Newsgroups: pl.comp.os.linux.programowanie
Subject: Re: daemon - przyklady
Date: Sun, 11 Oct 2009 12:27:04 +0200
Organization: http://onet.pl
Lines: 32
Message-ID: <hasbt8$l97$1@news.onet.pl>
References: <f7af2e8a-0a9e-4678-94ef-5aaf5c72a3ff@y21g2000yqn.googlegroups.com>
NNTP-Posting-Host: c2-211.icpnet.pl
Mime-Version: 1.0
X-Trace: news.onet.pl 1255256808 21799 62.21.2.211 (11 Oct 2009 10:26:48 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Sun, 11 Oct 2009 10:26:48 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.19 (X11/20090105)
In-Reply-To: <f7af2e8a-0a9e-4678-94ef-5aaf5c72a3ff@y21g2000yqn.googlegroups.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit