Feeds:
Posts
Comments

Posts Tagged ‘process’

Linux process segment layout

Advertisements

Read Full Post »

daemon, orphan, zombie process

  • Daemon: On Unix or other computer multitasking operating program, a daemon is a computer program that runs in the background. In Unix environment, the parent process of Daemon is often init process(PID=1). Process usually become daemon by forking a child and exit the parents immediately, thus cause init to adopt the child process.
  • Orphan: An orphan process is a computer process whose parent process has finished or terminated, though itself remains running. In a Unix-like operating system, any orphaned process will be immediately adopted by the init process.  A process may be intentionally orphaned so that it becomes detached from the user’s session and left running in the background. Usually to allow a long-running job to complete without further user attention, or to start an indefinitely running service(This kind of orphaned process usually called Daemon)
  • Zombie: On Unix and Unix-like computer OS, a zombie process is a process that completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the process to read its exit status. Unlike normal process, the kill() call has no effect on a zombie process. When a process ends, all the memory and resources are deallocated so they can be used by other process. However, the process’s entry in the process table remains. The parent can read the child’s exit status by wait() system calls, at which stage the zombie are removed.

A zombie process is not the same as an orphan process. An orphan process is a process that is still executing, but whose parent has died. They do not become zombie     processes; instead, they are adopted by init(PID 1), which wait() on its children.

Read Full Post »

Daemonize

Definition:

A daemon is a background process designed to run autonomously with little or no user intervention.

Structure:

  1. Fork off the parent process
  2. Change file create mode using umask()
  3. Open log for writing
  4. Create a unique session ID using setsid()
  5. Change the current work directory to a safe place
  6. Close standard file descriptors
  7. Actual jobs of the Daemon

Read Full Post »