svn commit: r251078 - head/bin/sleep

Jilles Tjoelker jilles at FreeBSD.org
Tue May 28 22:07:32 UTC 2013


Author: jilles
Date: Tue May 28 22:07:31 2013
New Revision: 251078
URL: http://svnweb.freebsd.org/changeset/base/251078

Log:
  sleep: Improve nanosleep() error handling:
  
   * Work around kernel bugs that cause a spurious [EINTR] return if a
     debugger (such as truss(1)) is attached.
  
   * Write an error message if an error other than [EINTR] occurs.
  
  PR:		bin/178664

Modified:
  head/bin/sleep/sleep.c

Modified: head/bin/sleep/sleep.c
==============================================================================
--- head/bin/sleep/sleep.c	Tue May 28 22:07:23 2013	(r251077)
+++ head/bin/sleep/sleep.c	Tue May 28 22:07:31 2013	(r251078)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 
 #include <ctype.h>
 #include <err.h>
+#include <errno.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdint.h>
@@ -87,8 +88,8 @@ main(int argc, char *argv[])
 			warnx("about %d second(s) left out of the original %d",
 			    (int)time_to_sleep.tv_sec, (int)original);
 			report_requested = 0;
-		} else
-			break;
+		} else if (errno != EINTR)
+			err(1, "nanosleep");
 	}
 	return (0);
 }


More information about the svn-src-all mailing list