mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2025-01-08 04:29:34 +00:00
re-set child signal handlers to default.
This commit is contained in:
parent
bc2381a360
commit
e51e757556
22
command.cpp
22
command.cpp
@ -18,6 +18,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sysexits.h>
|
||||
#include <signal.h>
|
||||
#include <atomic>
|
||||
|
||||
extern std::atomic<int> control_c;
|
||||
@ -124,8 +125,11 @@ fs::path which(const Environment &env, const std::string &name) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void launch_mpw(const Environment &env, const std::vector<std::string> &argv, const fdmask &fds) {
|
||||
|
||||
|
||||
std::vector<char *> cargv;
|
||||
cargv.reserve(argv.size() + 3);
|
||||
|
||||
@ -154,6 +158,24 @@ void launch_mpw(const Environment &env, const std::vector<std::string> &argv, co
|
||||
// handle any indirection...
|
||||
fds.dup();
|
||||
|
||||
|
||||
// re-set all signal handlers.
|
||||
|
||||
/*
|
||||
* execv modifies handlers as such:
|
||||
* blocked -> blocked
|
||||
* ignored -> ignored
|
||||
* caught -> default action
|
||||
*/
|
||||
struct sigaction sig_action;
|
||||
|
||||
sig_action.sa_handler = SIG_DFL;
|
||||
sig_action.sa_flags = 0;
|
||||
sigemptyset(&sig_action.sa_mask);
|
||||
for (int i = 1; i < NSIG; ++i) {
|
||||
sigaction(i, &sig_action, NULL);
|
||||
}
|
||||
|
||||
execv(mpw_path().c_str(), cargv.data());
|
||||
perror("execvp: ");
|
||||
exit(EX_OSERR); // raise a signal?
|
||||
|
Loading…
Reference in New Issue
Block a user