> Date: Mon, 21 Sep 2015 01:37:27 -0700
> From: Philip Guenther <guent...@gmail.com>
> 
> POSIX no longer requires sleep(1) to exit with status zero when sent 
> SIGALRM:
> 
> ----
>   If the sleep utility receives a SIGALRM signal, one of the following 
>   actions shall be taken:
> 
>    1. Terminate normally with a zero exit status.
> 
>    2. Effectively ignore the signal.
> 
>    3. Provide the default behavior for signals described in the
>       ASYNCHRONOUS EVENTS section of Section 1.4 (on page 2310).
>       This could include terminating with a non-zero exit status.
> ----
> 
> AFAICT, we don't use SIGALRM in any of our install or rc scripting, so 
> let's remove the unnecessary signal work.
> 
> ok?

Why?  The standard still allows our current behaviour.  And it's not a
particular invasive bit of code.

> Index: bin/sleep/sleep.1
> ===================================================================
> RCS file: /data/src/openbsd/src/bin/sleep/sleep.1,v
> retrieving revision 1.21
> diff -u -p -r1.21 sleep.1
> --- bin/sleep/sleep.1 27 May 2014 13:50:52 -0000      1.21
> +++ bin/sleep/sleep.1 21 Sep 2015 08:32:57 -0000
> @@ -51,11 +51,6 @@ suspends execution for a minimum of the 
>  This number must be positive and may contain a decimal fraction.
>  .Nm
>  is commonly used to schedule the execution of other commands (see below).
> -.Sh ASYNCHRONOUS EVENTS
> -.Bl -tag -width "SIGALRMXXX"
> -.It Dv SIGALRM
> -Terminate normally, with a zero exit status.
> -.El
>  .Sh EXIT STATUS
>  .Ex -std sleep
>  .Sh EXAMPLES
> Index: bin/sleep/sleep.c
> ===================================================================
> RCS file: /data/src/openbsd/src/bin/sleep/sleep.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 sleep.c
> --- bin/sleep/sleep.c 21 Nov 2013 15:54:46 -0000      1.20
> +++ bin/sleep/sleep.c 21 Sep 2015 08:21:26 -0000
> @@ -33,7 +33,6 @@
>  #include <ctype.h>
>  #include <errno.h>
>  #include <locale.h>
> -#include <signal.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <time.h>
> @@ -42,7 +41,6 @@
>  extern char *__progname;
>  
>  void usage(void);
> -void alarmh(int);
>  
>  int
>  main(int argc, char *argv[])
> @@ -56,8 +54,6 @@ main(int argc, char *argv[])
>  
>       setlocale(LC_ALL, "");
>  
> -     signal(SIGALRM, alarmh);
> -
>       while ((ch = getopt(argc, argv, "")) != -1)
>               switch(ch) {
>               default:
> @@ -115,19 +111,4 @@ usage(void)
>  {
>       (void)fprintf(stderr, "usage: %s seconds\n", __progname);
>       exit(1);
> -}
> -
> -/*
> - * POSIX 1003.2 says sleep should exit with 0 return code on reception
> - * of SIGALRM.
> - */
> -/* ARGSUSED */
> -void
> -alarmh(int signo)
> -{
> -     /*
> -      * exit() flushes stdio buffers, which is not legal in a signal
> -      * handler. Use _exit().
> -      */
> -     _exit(0);
>  }
> 
> 

Reply via email to