.\" From: NetBSD: daemon.3,v 1.3 1995/02/25 13:41:12 cgd Exp .\" $Id: daemon.3,v 1.1 2000/10/13 16:36:35 ysato Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)daemon.3 8.1 (Berkeley) 6/9/93 .\" .\" .\" Japanese Version Copyright (c) 2000 Yuichi SATO .\" all rights reserved. .\" Translated Fri Oct 20 00:12:05 JST 2000 .\" by Yuichi SATO .\" .\"WORD: detach 分離 .\"WORD: controlling terminal 制御端末 .\"WORD: current working directory カレント・ワーキング・ディレクトリ .\" .Dd June 9, 1993 .Dt DAEMON 3 .Os "Linux NetKit (0.17)" .Sh 名前 .Nm daemon .Nd バックグラウンドで動作させる .Sh 書式 .Fd #include .Fn daemon "int nochdir" "int noclose" .Sh 説明 .Pp .Fn daemon は、制御端末から分離させてシステムデーモンとして動作させたい プログラムのための関数である。 .Pp 引き数 .Fa nochdir が 0 の場合、 .Fn daemon は、カレント・ワーキング・ディレクトリをルート (``/'') に変更する。 .Pp 引き数 .Fa noclose が 0 の場合、 .Fn daemon は、標準入力・標準出力・標準エラーを ``\fI/dev/null\fP'' に送る。 .Sh エラー .Fn daemon 関数が失敗した場合、 .Va errno はライブラリ関数 .Xr fork 2 , .Xr setsid 2 に対して指定されたエラーに設定される。 .Sh 関連項目 .Xr setsid 2 .Sh 履歴 .Fn daemon 関数は .Bx 4.4 で初めて登場した。