Linux Application Development-Daemon

Source: Internet
Author: User

Linux Application Development-Daemon Linux application Development-Daemon
A daemon process
Default running process in the background

Two links to Android's services

Three-daemon process writing


1 out of control terminal TTY, let parent process be init
2 Disable process re-opening control terminal

3 re-open session setsid ();

4 Closes the open file descriptor, where the process inherits the open file descriptor from the parent process that created it

, failure to shut down will result in resource wastage, resulting in the inability of the filesystem to unload and cause unforeseen errors

You can use the For loop to close
for (i = 0; i < number of file descriptors; i++)
{
Close (i);
}

5 Changing the current working directory
Process activity is that the file system in which the working directory resides cannot be written down, and it is generally necessary to change the working directory to the root directory
chdir ()
6 reset umask (0)
Process from the creation of his parent process where the file creation mask continues, it may modify the village interest of the file created by the daemon

7 Modify RC file or Inittab file, can boot automatically
8 Results

Four kills the daemon process
Kill PID (with permissions)

Support for the five daemon processes

1 Core services are usually executed in a separate process

2 The application must be allowed to process communication across processes

3 multithreading security must be ensured because of sharing

4 Life cycle Management (SM)

Linux Application Development-Daemon

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.