OSDN Git Service

7a76b89547262238d17e147685b4142319107a47
[linuxjm/LDP_man-pages.git] / draft / man3 / daemon.3
1 .\" Copyright (c) 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. All advertising materials mentioning features or use of this software
14 .\"    must display the following acknowledgement:
15 .\"     This product includes software developed by the University of
16 .\"     California, Berkeley and its contributors.
17 .\" 4. Neither the name of the University nor the names of its contributors
18 .\"    may be used to endorse or promote products derived from this software
19 .\"    without specific prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\" %%%LICENSE_END
33 .\"
34 .\"     @(#)daemon.3    8.1 (Berkeley) 6/9/93
35 .\" Added mentioning of glibc weirdness wrt unistd.h. 5/11/98, Al Viro
36 .\"*******************************************************************
37 .\"
38 .\" This file was generated with po4a. Translate the source file.
39 .\"
40 .\"*******************************************************************
41 .TH DAEMON 3 2009\-12\-05 GNU "Linux Programmer's Manual"
42 .SH 名前
43 daemon \- バックグラウンドで動作させる
44 .SH 書式
45 \fB#include <unistd.h>\fP
46 .sp
47 \fBint daemon(int \fP\fInochdir\fP\fB, int \fP\fInoclose\fP\fB);\fP
48 .sp
49 .in -4n
50 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
51 .in
52 .sp
53 \fBdaemon\fP(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
54 .SH 説明
55 \fBdaemon\fP()  は、制御端末から分離させてシステムデーモンとして動作させたい プログラムのための関数である。
56 .PP
57 \fInochdir\fP が 0 の場合、 \fBdaemon\fP()  は呼び出したプロセスの現在の作業ディレクトリ (current working
58 directory)  をルートディレクトリ ("/") に変更する。 それ以外の場合、現在の作業ディレクトリは変更されない。
59 .PP
60 \fInoclose\fP が 0 の場合、 \fBdaemon\fP()  は標準入力・標準出力・標準エラーを \fI/dev/null\fP にリダイレクトする。
61 それ以外の場合、これらのファイル・ディスクリプタは変更されない。
62 .SH 返り値
63 .\" not .IR in order not to underline _
64 (この関数が fork して \fBfork\fP(2)  が成功すると、親プロセスでは \fB_exit\fP(2)
65 を呼び出すので、これ以降のエラーは子プロセスからしか見れない)。 成功した場合、 \fBdaemon\fP()  は 0 を返す。 エラーが起こった場合、
66 \fBdaemon\fP()  は \-1 を返す。 さらに、 \fIerrno\fP に \fBfork\fP(2)  と \fBsetsid\fP(2)
67 に関して規定されたエラーを設定する。
68 .SH 準拠
69 POSIX.1\-2001 にはない。 同様の関数が BSD には見られる。 \fBdaemon\fP()  関数は 4.4BSD で始めて登場した。
70 .SH 注意
71 \fI/dev/null\fP は存在するが、想定するメジャー番号とマイナー番号の キャラクタデバイスでなかった場合、 glibc の実装でも \-1
72 が返される。 この場合、 \fIerrno\fP が設定される必要はない。
73 .SH 関連項目
74 \fBfork\fP(2), \fBsetsid\fP(2)
75 .SH この文書について
76 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
77 である。プロジェクトの説明とバグ報告に関する情報は
78 http://www.kernel.org/doc/man\-pages/ に書かれている。