-
Notifications
You must be signed in to change notification settings - Fork 710
Expand file tree
/
Copy pathsignal.h
More file actions
48 lines (41 loc) · 1.08 KB
/
signal.h
File metadata and controls
48 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* This file is part of libnvme.
* Copyright (c) 2026 Micron Technology, Inc.
*
* Cross-platform compatibility for signal.h.
* Provides functionality that may be missing on some platforms.
* Compatibility is not comprehensive. Only functionality required by
* nvme-cli and libnvme is included.
*
* Authors: Brandon Busacker <[email protected]>
*/
#pragma once
#include <signal.h>
#if defined(_WIN32)
/* signal.h POSIX compatibility - Windows doesn't have sigaction */
struct sigaction {
void (*sa_handler)(int);
int sa_flags;
int sa_mask; /* simplified - normally sigset_t */
};
static inline int sigemptyset(int *set)
{
*set = 0;
return 0;
}
/*
* Simplified signal handling using Windows signal() function
* This is sufficient for handling SIGINT with no mask or flags.
*/
static inline int sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact)
{
(void)oldact; /* ignore old action for simplicity */
if (act && act->sa_handler) {
signal(signum, act->sa_handler);
return 0;
}
return -1;
}
#endif