UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Processes
  • » what is demonization??how to demonize a process?????

#1 2010-08-07 09:07 AM

shreesravan
Member
Registered: 2010-08-07
Posts: 3

Re: what is demonization??how to demonize a process?????

please help me  regarding demonization in UNIX...

Offline

#2 2010-08-07 09:29 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: what is demonization??how to demonize a process?????

See the daemon(3) manpage for a short overview. The main thing of daemonizing
is going into the background without quiting or holding anything up. A list of
things a process can do to achieve this:

- fork()
- setsid()
- close/redirect stdin/stdout/stderr to /dev/null, and/or ignore SIGHUP/SIGPIPE.
- chdir() to /.

If started as a root process, you also want to do the things you need to be root
for first, and then drop privileges. That is, change effective user to the "daemon"
user or "nobody" with setuid()/setgid(). If you can't drop all privileges and need
root access sometimes, use seteuid() to temporary drop it when not needed.

If you're a forking daemon then also setup child handlers and, if calling exec,
set the close on exec flags on all file descriptors your childs won't need.

Offline

#3 2010-08-07 09:41 AM

shreesravan
Member
Registered: 2010-08-07
Posts: 3

Re: what is demonization??how to demonize a process?????

Thanks for the reply!!!

Offline

  • Index
  • » Processes
  • » what is demonization??how to demonize a process?????

Board footer

Powered by FluxBB