Article View: cn.comp.os.linux
Article #14140Re: �ҵ��˹����ػ���̵Ķ�������ҷ���һ�¿���
From: rabbit_8
Date: Fri, 26 Oct 2001 00:28
Date: Fri, 26 Oct 2001 00:28
66 lines
3806 bytes
3806 bytes
�ҿ��ܶ������д˾䲻�ã�
signal(SIGHUP,SIG_IGN); /*����SIGHUP�ź�*/
On 23 Jun 2001 23:45:43 +800, "leftatrium" <leftatrium@21cn.com>
wrote:
> �ػ���̵ĸ���ͽ�������
>
> Linux����ָ�� http://lamli.go.163.com
> bigluo@china.com
>
>
> �ػ������һ�ֺ�̨���б�Ӷ����������ն˿���֮��Ľ��.
>
> ������Ϊ�ػ���̶��������е��ն˿���,���,������ͨ������������Ϣֱ
>�������������ͱ��������.��������������,linux�ṩ��syslog()����.ͨ��
>��,�ػ���̿�����ϵͳ��log�ļ�д����Ϣ.����ϵͳ�����syslog.h�еĶ�������:
> void syslog(int priority,char *format,...);
> ��һ�����ʹ��syslog()��ʱ��,Ӧ������openlog()��ϵͳ��¼.
>
> #include <syslog.h>
> void openlog(const *ident,int options,int facility);
> ����ident��һ���ַ��,ͨ�����dz��������.
> options�����������ֵ.
> LOG_CONS �����д��LOGֵ.��ֱ�ӽ��䷢������̨.
> LOG_NDELAY ֱ�ӽ���SYSLOGD��̶��Ǵ�LOG�ļ�
> LOG_PERROR ����Ϣд��LOGͬʱҲ������������.
> LOG_PID ��ÿ����Ϣ�м���PIDֵ.��һ��
>
> ������һ��ʾ��������:
> #include <sys/types.h>
> #include <signal.h>
> #include <unistd.h>
> #include <syslog.h>
>
> #define MAXFD 64
>
> main(){
>
> int i;
>
> if(fork())
> exit(1); /*������˳�,ʹ�ӽ�̳�Ϊ��̨���*/
>
> setsid(); /*����һ���µĽ����,������µĽ������,�ӽ�̳�Ϊ��������
>�����.����,�ý�̾Ͷ����������ն�֮��*/
>
> signal(SIGHUP,SIG_IGN); /*����SIGHUP�ź�*/
>
> if(fork())
> exit(1); /*�ٴ�fork(),��֤�ý�̲��ǽ��������.*/
>
> chdir("/"); /*�ı䵱ǰĿ¼,ʹ�ý�̲����κ��ļ�ϵͳ����*/
>
> unmask(0); /*����ļ�����,���������������ļ���Ӱ��*/
>
> for(i=0;i<MAXFD;i++)
> close(i); /*�ر������ļ�������*/
>
> openlog(pname,LOG_PID,facility); /*��¼*/
> }
>
>
>
>
>
Technical Details
Message-ID:
<3bd8ae11.261229127@news.cn99.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.cn99.com!not-for-mailReferences:
<677_445_A921.993311143.8427@www.webking.com.cn>Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: 10b277,d25007e9a54c7ee3,start X-Google-Attributes: gid10b277,public X-Google-ArrivalTime: 2001-10-25 17:26:35 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.cn99.com!not-for-mail From: rabbit_8@163.com Newsgroups: cn.comp.os.linux Subject: Re: �ҵ��˹����ػ���̵Ķ�������ҷ���һ�¿��� Date: Fri, 26 Oct 2001 00:28:44 GMT Organization: Bentium Ltd. (CN99) Lines: 67 Message-ID: <3bd8ae11.261229127@news.cn99.com> References: <677_445_A921.993311143.8427@www.webking.com.cn> NNTP-Posting-Host: 61.177.65.77 X-Trace: mail.cn99.com 1004055993 20969 61.177.65.77 (26 Oct 2001 00:26:33 GMT) X-Complaints-To: usenet@news.cn99.com NNTP-Posting-Date: Fri, 26 Oct 2001 00:26:33 +0000 (UTC) X-Newsreader: Forte Free Agent 1.11/32.235