SigFn
Loading...
Searching...
No Matches
sigfn.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Maxtek Consulting
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef SIGFN_H
24#define SIGFN_H
25
32#include <stdint.h>
33#include <stdlib.h>
34#include <signal.h>
35
36#ifdef __cplusplus
37extern "C"
38{
39#endif
40
41#ifdef _WIN32
42#define DLL_EXPORT __declspec(dllexport)
43 struct timeval
44 {
45 uint64_t tv_sec;
46 uint64_t tv_usec;
47 };
48#else
49#define DLL_EXPORT
50#include <sys/time.h>
51#endif
52
59 typedef void (*sigfn_handler_func)(int signum, void *userdata);
60
69 DLL_EXPORT int sigfn_handle(int signum, sigfn_handler_func handler, void *userdata);
70
77 DLL_EXPORT int sigfn_ignore(int signum);
78
85 DLL_EXPORT int sigfn_reset(int signum);
86
95 DLL_EXPORT int sigfn_wait(const int *signums, size_t count, int *received);
96
106 DLL_EXPORT int sigfn_wait_for(const int *signums, size_t count, int *received, const struct timeval *timeout);
107
117 DLL_EXPORT int sigfn_wait_until(const int *signums, size_t count, int *received, const struct timeval *deadline);
118
124 DLL_EXPORT const char *sigfn_error();
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif
DLL_EXPORT const char * sigfn_error()
get the last error message
#define DLL_EXPORT
Definition sigfn.h:49
DLL_EXPORT int sigfn_wait(const int *signums, size_t count, int *received)
wait for any of the specified signals
DLL_EXPORT int sigfn_ignore(int signum)
ignore a specific signal
DLL_EXPORT int sigfn_wait_for(const int *signums, size_t count, int *received, const struct timeval *timeout)
wait for any of the specified signals with a timeout
DLL_EXPORT int sigfn_reset(int signum)
reset a specific signal to its default behavior
DLL_EXPORT int sigfn_wait_until(const int *signums, size_t count, int *received, const struct timeval *deadline)
wait for any of the specified signals until a deadline
DLL_EXPORT int sigfn_handle(int signum, sigfn_handler_func handler, void *userdata)
attach handler to specific signal
void(* sigfn_handler_func)(int signum, void *userdata)
signal handler function type
Definition sigfn.h:59