Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 07, 2005 Daemon app in D | ||||
---|---|---|---|---|
| ||||
Is it possible to create a (linux) daemon in D? And if; how? Thnx |
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Geert |
Read samples in DMD distribution - there is one example there I think.
--
...........
Dejan Lekic
http://dejan.lekic.org
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | No, it is a windows server or something..
I need a real daemon that disconnects from the shell.
Dejan Lekic wrote:
> Read samples in DMD distribution - there is one example there I think.
>
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Geert | In article <d840t0$2881$1@digitaldaemon.com>, Geert says... > >No, it is a windows server or something.. >I need a real daemon that disconnects from the shell. > >Dejan Lekic wrote: >> Read samples in DMD distribution - there is one example there I think. >> I've done this before, and it needs to be done with linux system calls. There's no real nice D way to do it. I can't dig up an example of mine for you right now, but I'll get one for you later. Regards, James Dunne |
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to James Dunne | Thanks, that would be great...
James Dunne wrote:
> In article <d840t0$2881$1@digitaldaemon.com>, Geert says...
>
>>No, it is a windows server or something..
>>I need a real daemon that disconnects from the shell.
>>
>>Dejan Lekic wrote:
>>
>>>Read samples in DMD distribution - there is one example there I think.
>>>
>
>
> I've done this before, and it needs to be done with linux system calls. There's
> no real nice D way to do it. I can't dig up an example of mine for you right
> now, but I'll get one for you later.
>
> Regards,
> James Dunne
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Geert |
So you cannot write an simple D application that reads stdin, writes to stdout, uses inetd and you run it via "myprog [params] &" ?
--
...........
Dejan Lekic
http://dejan.lekic.org
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | It doesn't really detach the app from the shell.. Try for instance typing Ctrl-Z and then fg, it will bring back the app to the foreground.
Dejan Lekic wrote:
> So you cannot write an simple D application that reads stdin, writes to
> stdout, uses inetd and you run it via "myprog [params] &" ?
>
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Geert | On Tue, 07 Jun 2005 12:56:22 +0200, Geert wrote:
> Is it possible to create a (linux) daemon in D? And if; how?
>
> Thnx
An
extern (C) fork ();
somewhere, and then
if (fork ()) exit (0);
at the place you want your daemon to daemonize should be enough (since the point is that processes of which the parents are dead are adopted by init, and therefore become deamons).
That's what my server uses, and that's the standard way to do it afaict.
SeeSchloss.
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to SeeSchloss | On Tue, 07 Jun 2005 18:42:36 +0200, SeeSchloss wrote:
> extern (C) fork ();
or rather "extern (C) int fork ();", sorry
|
June 07, 2005 Re: Daemon app in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to SeeSchloss | Thanks, but the program will continue to be connected to the shell try this for instance:
extern (C) int fork ();
void main()
{
// fork returns -1 on failure
// 0 to childprocess, and the pid
// number of the child process to the parent
if(fork()) exit(0);
while(1)
printf("You will see this output.\n");
}
SeeSchloss wrote:
> On Tue, 07 Jun 2005 18:42:36 +0200, SeeSchloss wrote:
>
>
>>extern (C) fork ();
>
>
> or rather "extern (C) int fork ();", sorry
|
Copyright © 1999-2021 by the D Language Foundation