Home | History | Annotate | Line # | Download | only in gen
signalnext.c revision 1.1.2.2
      1  1.1.2.2  pgoyette /* $NetBSD: signalnext.c,v 1.1.2.2 2017/05/11 02:58:32 pgoyette Exp $ */
      2  1.1.2.2  pgoyette 
      3  1.1.2.2  pgoyette /*
      4  1.1.2.2  pgoyette  * Software available to all and sundry without limitations
      5  1.1.2.2  pgoyette  * but without warranty of fitness for any purpose whatever.
      6  1.1.2.2  pgoyette  *
      7  1.1.2.2  pgoyette  * Licensed for any use, including redistribution in source
      8  1.1.2.2  pgoyette  * and binary forms, with or without modifications, subject
      9  1.1.2.2  pgoyette  * the following agreement:
     10  1.1.2.2  pgoyette  *
     11  1.1.2.2  pgoyette  * Licensee agrees to indemnify licensor, and distributor, for
     12  1.1.2.2  pgoyette  * the full amount of any any claim made by the licensee against
     13  1.1.2.2  pgoyette  * the licensor or distributor, for any action that results from
     14  1.1.2.2  pgoyette  * any use or redistribution of this software, plus any costs
     15  1.1.2.2  pgoyette  * incurred by licensor or distributor resulting from that claim.
     16  1.1.2.2  pgoyette  *
     17  1.1.2.2  pgoyette  * This licence must be retained with the software.
     18  1.1.2.2  pgoyette  */
     19  1.1.2.2  pgoyette 
     20  1.1.2.2  pgoyette #include <sys/types.h>
     21  1.1.2.2  pgoyette 
     22  1.1.2.2  pgoyette #include <signal.h>
     23  1.1.2.2  pgoyette #include <string.h>
     24  1.1.2.2  pgoyette 
     25  1.1.2.2  pgoyette /*
     26  1.1.2.2  pgoyette  * signalnext()
     27  1.1.2.2  pgoyette  *
     28  1.1.2.2  pgoyette  *	Returns the next signal number after the one given.
     29  1.1.2.2  pgoyette  *	Giving 0 as 'sig' requests the lowest available signal number.
     30  1.1.2.2  pgoyette  *
     31  1.1.2.2  pgoyette  * Returns:
     32  1.1.2.2  pgoyette  *	-1 on error (invalid 'sig' arg)
     33  1.1.2.2  pgoyette  *	0  when there is no next.
     34  1.1.2.2  pgoyette  *	otherwise the next greater implemented signal number after 'sig'
     35  1.1.2.2  pgoyette  */
     36  1.1.2.2  pgoyette 
     37  1.1.2.2  pgoyette int
     38  1.1.2.2  pgoyette signalnext(int sig)
     39  1.1.2.2  pgoyette {
     40  1.1.2.2  pgoyette 
     41  1.1.2.2  pgoyette 	if (sig < 0 || sig >= NSIG || (sig > 0 && sys_signame[sig] == NULL))
     42  1.1.2.2  pgoyette 		return -1;
     43  1.1.2.2  pgoyette 
     44  1.1.2.2  pgoyette 	while (++sig < NSIG)
     45  1.1.2.2  pgoyette 		if (sys_signame[sig] != NULL)
     46  1.1.2.2  pgoyette 			return sig;
     47  1.1.2.2  pgoyette 
     48  1.1.2.2  pgoyette 	return 0;
     49  1.1.2.2  pgoyette }
     50