⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program-deamon.html

📁 学习linux的工具书
💻 HTML
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
   <meta name="Author" content="Edward Fu">
   <meta name="GENERATOR" content="Mozilla/4.05 [zh-CN] (X11; I; Linux 2.1.127 i686) [Netscape]">
   <title>Freesoft Linux FAQ -- 如何写一个Deamon程序</title>
</head>
<body>
如何写一个deamon程序?
<br>&nbsp;
<br>发信站: BBS 水木清华站 (Fri Nov 27 01:22:52 1998)
<br>【 在 gjx (小侃帝) 的大作中提到: 】
<br>:&nbsp; as titile who can tell me !
<br>:&nbsp; thansks
<br>&nbsp;
<br>1> ignore the signals, SIGINT, SIGQUIT, SIGTRAP, SIGIOT, SIGTERM, etc
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signal(xxx,SIGIGN);
<br>2> close all the file descriptors
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=32,i>=3,i--)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
close(i);
<br>3> fork (maybe twice)
<br>4> chdir("/")
<br>5> umask(0)
<br>6> call setpgrp() to become the head of the new process group
<br>&nbsp;
<br>Some steps can be omitted.
<br>You can make it. Good luck!
<br>&nbsp;
<br>--
<br>注:另外在《Linux从入门到精通》书中也有讲解。
<br>&nbsp;
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -