cht電腦資訊gcin已解決問題
adm Find login register

[patch] 用 nanosleep 取代 sleep 和 usleep

caleb
joined: 2007-09-22
posted: 630
promoted: 134
bookmarked: 90
1subject: [patch] 用 nanosleep 取代 sleep 和 usleepPromote 0 Bookmark 02009-05-22quote  

如附件。

Compared to sleep(3) and usleep(3), nanosleep() has the advantage of not affecting any signals, it is standardized by POSIX, it provides higher timing resolution, and it allows to continue a sleep that has been interrupted by a signal more easily.

Security issue:
[1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command
  by the same name).   The interaction of this function with SIGALRM and
  other timer functions such as sleep(), alarm(), setitimer(), and
  nanosleep() is unspecified. Use nanosleep(2) or setitimer(2) instead.

eliu

joined: 2007-08-09
posted: 11468
promoted: 617
bookmarked: 187
新竹, 台灣
2subject: Promote 0 Bookmark 02009-05-22quote  

我不覺得 signal 影響會造成什麼問題,如果從負面的影響來說,而且 nanosleep 多出來的 parameter 會讓 file size 變大。 大笑

edited: 2

cht電腦資訊gcin已解決問題
adm Find login register
views:6873