C语言 c、unix中的睡眠功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5019282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 07:49:46  来源:igfitidea点击:

sleep function in c, unix

cunix

提问by rach

What do i need to import to use the sleep function in unix? i know it's windows.h for windows, but what about unix?

我需要导入什么才能在 unix 中使用睡眠功能?我知道 windows.h 是 windows 的,但是 unix 呢?

回答by sstn

It should be in unistd.h.

它应该在 unistd.h 中。

Please note that this gives you only a precision of integral seconds.

请注意,这仅提供整数秒的精度。

The most portable way for sub-second precision should be (ab-)using select().

亚秒级精度的最便携方法应该是(ab-)使用 select()。