[Mauiusers] Patch to fix a possible double free

Ronny T. Lampert telecaadmin at gmail.com
Sat Aug 11 06:49:56 MDT 2007


> I'm not sure I understand what you mean by "daemon should duplicate all standard descriptors to
> /dev/null." Perhaps you can help me in my ignorance.

Ah, yes. Usually, fully background daemons close 0, 1 and 2 (stdin, out 
and err) and dup() them to /dev/null, and also do a setsid().

This prevents accidentially opened ttys (and sessions) to be held open 
or msgs (e.g. perror()) going somewhere where they possibly shouldn't.
One also could dup() them to a file, so all output goes there in case 
some library functions really wants to use stdout or -err.

I think closing stdin is quite crucial to correct operation, else the 
daemon could accidentially get blocked.

Cheers,
Ronny


More information about the mauiusers mailing list