mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
Kernel+LibC: Share definitions for signal.h
This commit is contained in:
parent
9dc1350177
commit
6fd7212476
4 changed files with 77 additions and 107 deletions
73
Kernel/API/POSIX/signal.h
Normal file
73
Kernel/API/POSIX/signal.h
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Kernel/API/POSIX/sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void (*__sighandler_t)(int);
|
||||||
|
typedef __sighandler_t sighandler_t;
|
||||||
|
|
||||||
|
typedef uint32_t sigset_t;
|
||||||
|
typedef uint32_t sig_atomic_t;
|
||||||
|
|
||||||
|
union sigval {
|
||||||
|
int sival_int;
|
||||||
|
void* sival_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct siginfo {
|
||||||
|
int si_signo;
|
||||||
|
int si_code;
|
||||||
|
pid_t si_pid;
|
||||||
|
uid_t si_uid;
|
||||||
|
void* si_addr;
|
||||||
|
int si_status;
|
||||||
|
union sigval si_value;
|
||||||
|
} siginfo_t;
|
||||||
|
|
||||||
|
struct sigaction {
|
||||||
|
union {
|
||||||
|
void (*sa_handler)(int);
|
||||||
|
void (*sa_sigaction)(int, siginfo_t*, void*);
|
||||||
|
};
|
||||||
|
sigset_t sa_mask;
|
||||||
|
int sa_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIG_DFL ((__sighandler_t)0)
|
||||||
|
#define SIG_ERR ((__sighandler_t)-1)
|
||||||
|
#define SIG_IGN ((__sighandler_t)1)
|
||||||
|
|
||||||
|
#define SA_NOCLDSTOP 1
|
||||||
|
#define SA_NOCLDWAIT 2
|
||||||
|
#define SA_SIGINFO 4
|
||||||
|
#define SA_ONSTACK 0x08000000
|
||||||
|
#define SA_RESTART 0x10000000
|
||||||
|
#define SA_NODEFER 0x40000000
|
||||||
|
#define SA_RESETHAND 0x80000000
|
||||||
|
|
||||||
|
#define SA_NOMASK SA_NODEFER
|
||||||
|
#define SA_ONESHOT SA_RESETHAND
|
||||||
|
|
||||||
|
#define SIG_BLOCK 0
|
||||||
|
#define SIG_UNBLOCK 1
|
||||||
|
#define SIG_SETMASK 2
|
||||||
|
|
||||||
|
#define CLD_EXITED 0
|
||||||
|
#define CLD_KILLED 1
|
||||||
|
#define CLD_DUMPED 2
|
||||||
|
#define CLD_TRAPPED 3
|
||||||
|
#define CLD_STOPPED 4
|
||||||
|
#define CLD_CONTINUED 5
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -811,7 +811,7 @@ bool Thread::should_ignore_signal(u8 signal) const
|
||||||
auto& action = m_signal_action_data[signal];
|
auto& action = m_signal_action_data[signal];
|
||||||
if (action.handler_or_sigaction.is_null())
|
if (action.handler_or_sigaction.is_null())
|
||||||
return default_signal_action(signal) == DefaultSignalAction::Ignore;
|
return default_signal_action(signal) == DefaultSignalAction::Ignore;
|
||||||
if (action.handler_or_sigaction.as_ptr() == SIG_IGN)
|
if ((sighandler_t)action.handler_or_sigaction.as_ptr() == SIG_IGN)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +923,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler_vaddr.as_ptr() == SIG_IGN) {
|
if ((sighandler_t)handler_vaddr.as_ptr() == SIG_IGN) {
|
||||||
dbgln_if(SIGNAL_DEBUG, "Ignored signal {}", signal);
|
dbgln_if(SIGNAL_DEBUG, "Ignored signal {}", signal);
|
||||||
return DispatchSignalResult::Continue;
|
return DispatchSignalResult::Continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/API/POSIX/fcntl.h>
|
#include <Kernel/API/POSIX/fcntl.h>
|
||||||
#include <Kernel/API/POSIX/netinet/in.h>
|
#include <Kernel/API/POSIX/netinet/in.h>
|
||||||
|
#include <Kernel/API/POSIX/signal.h>
|
||||||
#include <Kernel/API/POSIX/sys/mman.h>
|
#include <Kernel/API/POSIX/sys/mman.h>
|
||||||
#include <Kernel/API/POSIX/sys/socket.h>
|
#include <Kernel/API/POSIX/sys/socket.h>
|
||||||
#include <Kernel/API/POSIX/sys/stat.h>
|
#include <Kernel/API/POSIX/sys/stat.h>
|
||||||
|
@ -70,10 +71,6 @@ enum {
|
||||||
#define X_OK 1
|
#define X_OK 1
|
||||||
#define F_OK 0
|
#define F_OK 0
|
||||||
|
|
||||||
#define SIG_DFL ((void*)0)
|
|
||||||
#define SIG_ERR ((void*)-1)
|
|
||||||
#define SIG_IGN ((void*)1)
|
|
||||||
|
|
||||||
#define SEEK_SET 0
|
#define SEEK_SET 0
|
||||||
#define SEEK_CUR 1
|
#define SEEK_CUR 1
|
||||||
#define SEEK_END 2
|
#define SEEK_END 2
|
||||||
|
@ -148,51 +145,6 @@ struct tms {
|
||||||
clock_t tms_cstime;
|
clock_t tms_cstime;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*__sighandler_t)(int);
|
|
||||||
typedef __sighandler_t sighandler_t;
|
|
||||||
|
|
||||||
typedef u32 sigset_t;
|
|
||||||
|
|
||||||
union sigval {
|
|
||||||
int sival_int;
|
|
||||||
void* sival_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct siginfo {
|
|
||||||
int si_signo;
|
|
||||||
int si_code;
|
|
||||||
pid_t si_pid;
|
|
||||||
uid_t si_uid;
|
|
||||||
void* si_addr;
|
|
||||||
int si_status;
|
|
||||||
union sigval si_value;
|
|
||||||
} siginfo_t;
|
|
||||||
|
|
||||||
struct sigaction {
|
|
||||||
union {
|
|
||||||
void (*sa_handler)(int);
|
|
||||||
void (*sa_sigaction)(int, siginfo_t*, void*);
|
|
||||||
};
|
|
||||||
sigset_t sa_mask;
|
|
||||||
int sa_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SA_NOCLDSTOP 1
|
|
||||||
#define SA_NOCLDWAIT 2
|
|
||||||
#define SA_SIGINFO 4
|
|
||||||
#define SA_NODEFER 0x40000000
|
|
||||||
|
|
||||||
#define SIG_BLOCK 0
|
|
||||||
#define SIG_UNBLOCK 1
|
|
||||||
#define SIG_SETMASK 2
|
|
||||||
|
|
||||||
#define CLD_EXITED 0
|
|
||||||
#define CLD_KILLED 1
|
|
||||||
#define CLD_DUMPED 2
|
|
||||||
#define CLD_TRAPPED 3
|
|
||||||
#define CLD_STOPPED 4
|
|
||||||
#define CLD_CONTINUED 5
|
|
||||||
|
|
||||||
typedef i64 off_t;
|
typedef i64 off_t;
|
||||||
typedef i64 time_t;
|
typedef i64 time_t;
|
||||||
|
|
||||||
|
|
|
@ -6,41 +6,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Kernel/API/POSIX/signal.h>
|
||||||
#include <signal_numbers.h>
|
#include <signal_numbers.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
typedef void (*__sighandler_t)(int);
|
|
||||||
typedef __sighandler_t sighandler_t;
|
|
||||||
|
|
||||||
typedef uint32_t sigset_t;
|
|
||||||
typedef uint32_t sig_atomic_t;
|
|
||||||
|
|
||||||
union sigval {
|
|
||||||
int sival_int;
|
|
||||||
void* sival_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct siginfo {
|
|
||||||
int si_signo;
|
|
||||||
int si_code;
|
|
||||||
pid_t si_pid;
|
|
||||||
uid_t si_uid;
|
|
||||||
void* si_addr;
|
|
||||||
int si_status;
|
|
||||||
union sigval si_value;
|
|
||||||
} siginfo_t;
|
|
||||||
|
|
||||||
struct sigaction {
|
|
||||||
union {
|
|
||||||
void (*sa_handler)(int);
|
|
||||||
void (*sa_sigaction)(int, siginfo_t*, void*);
|
|
||||||
};
|
|
||||||
sigset_t sa_mask;
|
|
||||||
int sa_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
int kill(pid_t, int sig);
|
int kill(pid_t, int sig);
|
||||||
int killpg(int pgrp, int sig);
|
int killpg(int pgrp, int sig);
|
||||||
sighandler_t signal(int sig, sighandler_t);
|
sighandler_t signal(int sig, sighandler_t);
|
||||||
|
@ -60,30 +31,4 @@ const char* getsignalname(int);
|
||||||
|
|
||||||
extern const char* sys_siglist[NSIG];
|
extern const char* sys_siglist[NSIG];
|
||||||
|
|
||||||
#define SIG_DFL ((__sighandler_t)0)
|
|
||||||
#define SIG_ERR ((__sighandler_t)-1)
|
|
||||||
#define SIG_IGN ((__sighandler_t)1)
|
|
||||||
|
|
||||||
#define SA_NOCLDSTOP 1
|
|
||||||
#define SA_NOCLDWAIT 2
|
|
||||||
#define SA_SIGINFO 4
|
|
||||||
#define SA_ONSTACK 0x08000000
|
|
||||||
#define SA_RESTART 0x10000000
|
|
||||||
#define SA_NODEFER 0x40000000
|
|
||||||
#define SA_RESETHAND 0x80000000
|
|
||||||
|
|
||||||
#define SA_NOMASK SA_NODEFER
|
|
||||||
#define SA_ONESHOT SA_RESETHAND
|
|
||||||
|
|
||||||
#define SIG_BLOCK 0
|
|
||||||
#define SIG_UNBLOCK 1
|
|
||||||
#define SIG_SETMASK 2
|
|
||||||
|
|
||||||
#define CLD_EXITED 0
|
|
||||||
#define CLD_KILLED 1
|
|
||||||
#define CLD_DUMPED 2
|
|
||||||
#define CLD_TRAPPED 3
|
|
||||||
#define CLD_STOPPED 4
|
|
||||||
#define CLD_CONTINUED 5
|
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue