13th Chapter The Guardian process summary

Source: Internet
Author: User
Tags syslog

1 Writing daemon Basic rules

1) umake (0) Set the file mode creation screen Word to 0

2) after fork, the parent process exit

3) Child process call Setsid

4) Change the working directory ChDir ("/")

5) Close all open file descriptors

6) Open file descriptor on/dev/null

2 Daemon Process error handling

Three ways to generate log messages:

1) kernel process Call log function write log message to/dev/klog

2) User process calls Syslog function write log message to/dev/log

3) The process on the network host sends a log message UDP packet to 514 port

The syslogd daemon is used to process log messages, and the profile for this process is typically/etc/syslog.conf, which determines how different kinds of messages should be handled

#include <syslog.h>void openlog (constchar *ident,int option,int facility) void syslog (int priority,constchar *format,...) void Closelog (); int setlogmask (int maskpri)

Ident is typically the program name and will be added to each log message

13th Chapter The Guardian process summary

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.