.\" .\" $OpenBSD: nanosleep.2,v 1.1 1997/04/20 20:56:20 tholo Exp $ .\" %NetBSD: nanosleep.2,v 1.1 1997/04/17 18:12:02 jtc Exp % .\" .\" Copyright (c) 1986, 1991, 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. .\" .\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 .\" %FreeBSD: src/lib/libc/sys/nanosleep.2,v 1.17 2004/07/02 23:52:13 ru Exp % .\" .\" $FreeBSD$ .Dd April 17, 1997 .Dt NANOSLEEP 2 .Os .Sh 名称 .Nm nanosleep .Nd ナノ秒単位の間隔でプロセス実行を中断する .Sh ライブラリ .Lb libc .Sh 書式 .In time.h .Ft int .Fn nanosleep "const struct timespec *rqtp" "struct timespec *rmtp" .Sh 解説 .Fn nanosleep システムコールによってプロセスは指定の時間だけ休眠状態になります。 シグナルによる割り込み時の .Dv SA_RESTART 値に無関係に、マスクされていないシグナルがあると プロセスの休眠状態は早めに終了します。 .Sh 戻り値 要求された時間が経過したために .Fn nanosleep システムコールが戻った場合、返される値は 0 になります。 .Pp シグナルが配信されたために .Fn nanosleep システムコールから戻った場合に返される値は -1 になり、割り込みを示すために グローバル変数 .Va errno が設定されます。 .Fa rmtp が .Dv NULL でない場合、それが参照する timespec 構造体は非休眠時間で更新されます (要求時間から、実際に休眠状態にあった時間を減算したものです)。 .Sh エラー .Fn nanosleep システムコールは、次の場合に失敗します: .Bl -tag -width Er .It Bq Er EFAULT .Fa rqtp または .Fa rmtp のどちらかが、 プロセスに割り当てられたアドレス空間の範囲外のメモリを指しています。 .It Bq Er EINTR .Fn nanosleep システムコールはシグナルの配信によって割り込まれました。 .It Bq Er EINVAL .Fa rqtp 引数に 0 未満か、10 億ナノ秒以上の値を指定しました。 .It Bq Er ENOSYS .Fn nanosleep システムコールはこのシステムではサポートされていません。 .El .Sh 関連項目 .Xr sigsuspend 2 , .Xr sleep 3 .Sh 規格 .Fn nanosleep システムコールは .St -p1003.1b-93 に適合しています。