X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2Fsigwait.c;fp=sources%2Fsigwait.c;h=7dcc983af04b4d009aa30b78287ecf1ef88c4309;hp=0000000000000000000000000000000000000000;hb=f11c4bded73710805cee34fd90ca5e0f8e2559bd;hpb=f7a6ae8c2e5b4e412f1805db07582b1bc5ae4f06 diff --git a/sources/sigwait.c b/sources/sigwait.c new file mode 100644 index 0000000..7dcc983 --- /dev/null +++ b/sources/sigwait.c @@ -0,0 +1,66 @@ +/* sigwait.c + * + * Copyright (C) 2021 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/**************************************************************** + * + * Program sigwait.c: + * Test program for sigwait function + * + * Author: Simone Piccardi + * Nov. 2021 + * + ****************************************************************/ +/* + * Include needed headers + */ +#define _GNU_SOURCE +#include /* unix standard library */ +#include /* signal constants, types and functions */ +#include /* error definitions and routines */ +#include /* C standard library */ +#include /* unix standard library */ +#include /* standard I/O library */ +#include /* C strings library */ + +int main(int argc, char *argv[]) +{ +/* + * Variables definition + */ + int i; + pid_t pid = 0; + int sig,res; + sigset_t set; + + sigemptyset(&set); + sigaddset(&set, SIGALRM); +// while (1) { + res=sigwait(&set, &sig); + printf("Sig was %d", sig); + if ( res > 0) { + printf("Errno was %d", errno); + perror("errore"); + printf("Result was %d", res); + printf("Error by res was %s", strerror(res)); + exit(11); + } else { + printf("Result was %d", res); + printf("Normal exit"); + } +// } +}