Linux Daemon Writing HOWTO
This document shows how to write a daemon in Linux using GCC. Knowledge of Linux and a familiarity with C are necessary to use this document. This HOWTO is Copyright by Devin Watson, under the terms of the BSD License.
1. Introduction: What is a Daemon?
2. Getting Started
3. Planning Your Daemon
3.1 What Is It Going To Do?
3.2 How Much Interaction?
4. Basic Daemon Structure
4.1 Forking The Parent Process
4.2 Changing The File Mode Mask (Umask)
4.3 Opening Logs For Writing
4.4 Creating a Unique Session ID (SID)
4.5 Changing The Working Directory
4.6 Closing Standard File Descriptors
5. Writing the Daemon Code
5.1 Initialization
5.2 The Big Loop
6. Putting It All Together
6.1 Complete Sample
1. Introduction: What is a Daemon?
A daemon (or service) is a background process that is designed to run autonomously,with little or not user intervention. The Apache web server http daemon (httpd) is one such example of a daemon. It waits in the background listening on specific ports, and serves up pages or processes scripts, based on the type of request.
Creating a daemon in Linux uses a specific set of rules in a given order. Knowing how they work will help you understand how daemons operate in userland Linux, but can operate with calls to the kernel also. In fact, a few daemons interface with kernel modules that work with hardware devices, such as external controller boards, printers,and PDAs. They are one of the fundamental building blocks in Linux that give it incredible flexibility and power.
Throughout this HOWTO, a very simple daemon will be built in C. As we go along, more code will be added, showing the proper order of execution required to get a daemon up and running.
2. Getting Started
First off, you'll need the following packages installed on your Linux machine to develop daemons, specifically:
GCC 3.2.2 or higher
Linux Development headers and libraries
If your system does not already have these installed (not likely, but che
Ïà¹ØÎĵµ£º
Ò»£®Ìî¿ÕÌâ
1. ÔÚLinuxϵͳÖУ¬ÒÔ ·½Ê½·ÃÎÊÉ豸 ¡£
2. LinuxÄÚºËÒýµ¼Ê±£¬´ÓÎļþ ÖжÁÈ¡Òª¼ÓÔصÄÎļþϵͳ¡£
3. LinuxÎļþϵͳÖÐÿ¸öÎļþÓà À´±êʶ¡£
4. È«²¿´ÅÅÌ¿éÓÉËĸö²¿·Ö×é³É£¬·Ö±ðΪ ¡£
5. Á´½Ó·ÖΪ£º ºÍ ¡£
6. ³¬¼¶¿é°üº¬ÁË ºÍ µÈÖØÒªµÄÎļþϵͳÐÅÏ¢¡£
7. ijÎļþµÄȨÏÞΪ£ºdrw-r--r--£¬ÓÃÊýÖµÐÎʽ±íʾ¸ÃȨÏÞ£¬Ô ......
ת×Ô£ºhttp://www.linuxdiyf.com/bbs/viewthread.php?tid=106169
LinuxϽ¨ÒéʹÓÃvsftp£¬°²È«¼òµ¥ÊµÓÃ
vsftp¼´Very Security FTP£¬¹ËÃû˼Ò壬·Ç³£°²È«µÄFTP·þÎñÆ÷¡£
Ŀ¼
1 vsFTP·þÎñÆ÷µÄ°²×°
1.1 ÄäÃû·þÎñÆ÷µÄÁ¬½Ó£¨¶ÀÁ¢µÄ·þÎñÆ÷£©
1.2 ¿ªÆôÄäÃûFTP·þÎñÆ÷ÉÏ´«È¨ÏÞ
1.3 ¿ªÆôÄäÃû·þÎñÆ÷Ï´«µÄȨÏÞ
1.4 ......
1 ¡¢Ç°ÑÔ
¡¡¡¡×Ô´Óµ®ÉúÒÔÀ´£¬Linux ¾Í±»²»¶ÏÍêÉƺÍÆÕ¼°£¬Ä¿Ç°ËüÒѾ³ÉΪÖ÷Á÷ͨÓòÙ×÷ϵͳ֮һ£¬Ê¹Óõ÷dz£¹ã·º£¬ËüÓë Windows¡¢UNIX Ò»ÆðÕ¼¾ÝÁ˲Ù×÷ϵͳÁìÓò¼¸ºõËùÓеÄÊг¡·Ý¶î¡£ÌرðÊÇÔÚ¸ßÐÔÄܼÆËãÁìÓò£¬Linux ÒѾ³ÉΪһ¸öÕ¼Ö÷µ¼µØλµÄ²Ù×÷ϵͳ£¬ÔÚ2005Äê6ÔÂÈ«ÇòTOP500 ¼ÆËã»úÖУ¬ÓÐ 301 ̨²¿ÊðµÄÊÇ Linux ²Ù×÷ϵͳ¡£Òò ......
ÓÉÓÚÎҵĻúÆ÷ż¶û¿ª·¢Óã¬ËùÒÔ¿â±È½ÏÈ«¡£
ËùÒÔÈç¹ûÄú°²×°µÄʱºò£¬È±É¶²¹É¶°É~~
careone ´òdeb°ü~~
ÏÂÔØÒ³Ã棺http://forum.ubuntu.org.cn/viewtopic.php?f=137&t=217474
ÏÂÔصØÖ·£ºhttp://forum.ubuntu.org.cn/download/file.php?id=73080 ......
ÏÂÔØ
·ÉÐÅ»úÆ÷ÈËFetion ROBOT
µØÖ·£ºhttp://www.it-adv.net/index.php?action=downloads
°²×°
¿ÉÒԲο¼ÍøÒ³Éϵıê×¼·½·¨£¬ÓÐÏêϸ²½Ö裬»òÕßÒ²¿ÉÒÔ¿´Ò»ÏÂÎҵIJ½Ö裬http://blog.csdn.net/newman0708/archive/2009/02/15/3891871.aspx
ÃüÁîÐÐÓ÷¨
LD_LIBRARY_PATH=/home/newman0708/fetion_install/ /home/newman0708/f ......