> Hi all,
> 
> I'm attempting to write a simple daemon in mono that should
> background
> itself after starting correctly.  Essentially, it should fork() and
> then the parent should exit(0) while the child process continues.
> 
> I've gotten this working with the (apparently now obsolete)
> Mono.Posix.Syscall class.  However, in the newer
> Mono.Unix.Native.Syscall, we find this:
> 
> #if false
>                 // fork(2)
>                 //    pid_t fork(void);
>                 [DllImport (LIBC, SetLastError=true)]
>                 [Obsolete ("DO NOT directly call fork(2); it bypasses
> essential
>                                 "shutdown code.\nUse
> System.Diagnostics.Process
>                 private static extern int fork ();
> 
>                 // vfork(2)
>                 //    pid_t vfork(void);
>                 [DllImport (LIBC, SetLastError=true)]
>                 [Obsolete ("DO NOT directly call vfork(2); it bypasses
> essential
>                                 "shutdown code.\nUse
> System.Diagnostics.Process
>                 private static extern int vfork ();
> #endif
> 
> Apparently, fork() was originally marked obsolete, then commented out
> completely.
> 
> However, I don't understand the rationale here.  It seems to me that
> fork() has nothing to do with shutdown, and thus cannot possibly
> bypass "essential shutdown code."  On the other hand, Syscall.execve
> is *not* obsolete and *does* bypass shutdown code.  Furthermore, the
> recommended System.Diagnostics.Process class provides no equivalent
> to
> fork(), so I'm not sure why it's being recommended.
> 
> What's the rationale here?
> 
> Thanks,
> 
> Avery

Hi Avery,

I believe you can use mono-service and the usual Windows service stuff in the 
ServiceProcess assembly. Check 
http://www.go-mono.com/docs/index.aspx?link=man%3Amono-service(1)
for more info, and hopefully someone will be able to give more detail than
I have.

Sincerely,

Bojan
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to