[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Hvordan laver jeg en Daemon?



søn, 15 05 2011 kl. 20:06 +0200, skrev Robert Larsen:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 2011-05-01 15:07, Lars Nielsen wrote:
> > Hejsa,
> >
> > Jeg har en inde om at jeg vil lave en daemon til Debian 6, men de
> > informationer jeg har fundet via google er ca 5 år gamle. Er der nogen
> > der kan vise nogle links til hvordan jeg kan komme igang med sådan en
> > udvikling?
> >
> > mvh
> > Lars Nielsen
> >
> Hej
> 
> At lave daemoner er jo noget man har gjort længe, så selv 5 år gamle
> oplysninger er sandsynligvis fuldt up to date.
> Hvilket programmeringssprog vil du bruge ?
> 
> I C har Linux funktionen daemon(3), som gør næsten alt arbejdet.
> Ruby har Process.daemon, Python og Perl har sikkert noget lignende.
> 
> I PHP kan du bruge noget i denne stil:
> 
> function daemonize() {
>             //Fork off daemon
>             $pid = @pcntl_fork();
>             if ($pid === -1) {
>                 //Something went wrong
>                 return false;
>             }
>             if ($pid !== 0) {
>                 //Exit parent
>                 @exit(0);
>             }
> 
>             //Become session leader
>             $sessionid = @posix_setsid();
> 
>             //Change to root directory
>             if (sslug@sslug("/")) {
>                 return -1;
>             }
> 
>             //Do not die with controlling process
>             pcntl_signal(SIGHUP, SIG_IGN);
> 
>             return 0;
> }
> 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk3QFggACgkQzDMeisFqGZbz5gCfXA0RRpcjI3tdvciLKQFHHW79
> bbsAoO4cR4lsrIPnrla6DSuQ2yuxxyss
> =oT0T
> -----END PGP SIGNATURE-----
> 
Hej Robert,

Tak for din mail. Nu har jeg fået kigget lidt nærmere på sagerne, og har
lavet en lille daemon i c++ via fork() og set_sid() funktionerne. Det
ser ud til at daemon() funktionen blot er en wrapper omkring disse to
funktioner, men med noget fejlhåndtering indbygget.

Mvh Lars



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-06-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *