unix network programming (stevens, dumnezeu sa-l ierte) - si devii doctor;

pe scurt, daemon inseamna:

- fork()
- omori parintele
- setsid() (devii seful grupului)
- fork()
- omori parintele
- now nu mai ai drept de terminal ... stuff
- umask(0)

-tcp socket()
-bind()
-listen()
- while (accept())
  {
     fork();
     parintele continue;
     copilul: handle_request(accepted_socket);
  }

... have fun.

--vasile butnaru


On Fri, 22 Feb 2002, Serghei Amelian wrote:

|Acum vreau sa intre intr-o bucla si sa asculte un port.
|
|Serghei.
|
|On Friday 22 February 2002 18:25, you wrote:
|> salut,
|>
|>
|> cam asa e ..
|> ideea e sa faci un fork .. adica un fiu al procesului initial .. si apoi
|> omori pe tacso.. (criminala kestie)
|>
|> #include <stdio.h>
|> #include <unistd.h>
|>
|> int main()
|> {
|>      pid_t pid;
|>
|>      if ( (pid = fork()) < 0)
|>              exit(fprintf(stderr, "Fork error.\n"));
|>      else if (pid != 0)
|>              exit(0);
|>      puts("sunt daemon");
|>
|>         close(0); close(1); close(2);
|>
|>      /* de aici incolo e daemon  si ai stdin, out si err inchise*/
|>
|>      return 0;
|> }
|>
|> On Fri, 22 Feb 2002, Serghei Amelian wrote:
|> > Stie cineva unde pot gasi un exemplu despre cum se scrie un daemon
|> > simplu?
|> >
|> > Serghei.
|> > ---
|> > Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to
|> > unsubscribe from this list.
|>
|> -----
|> Ionut Spirlea,
|> http://sgi.rdscv.ro/~ionuts/
|>
|>
|> ---
|> Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to
|> unsubscribe from this list.
|---
|Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to 
|unsubscribe from this list.
|

-- 
--



---
Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to 
unsubscribe from this list.

Raspunde prin e-mail lui