mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
ncsubproc: memset() clone_args rather than by-field
This commit is contained in:
parent
34629688d9
commit
12050a8ca7
22
src/lib/fd.c
22
src/lib/fd.c
@ -92,24 +92,22 @@ int ncfdplane_destroy(ncfdplane* n){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME introduced in linux 5.5
|
||||||
|
#ifndef CLONE_CLEAR_SIGHAND
|
||||||
|
#define CLONE_CLEAR_SIGHAND 0x100000000ULL
|
||||||
|
#endif
|
||||||
|
|
||||||
static pid_t
|
static pid_t
|
||||||
launch_pipe_process(int* pipe, int* pidfd){
|
launch_pipe_process(int* pipe, int* pidfd){
|
||||||
int pipes[2];
|
int pipes[2];
|
||||||
if(pipe2(pipes, O_CLOEXEC)){ // can't use O_NBLOCK here (affects client)
|
if(pipe2(pipes, O_CLOEXEC)){ // can't use O_NBLOCK here (affects client)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
struct clone_args clargs = {
|
struct clone_args clargs;
|
||||||
.flags = CLONE_CLEAR_SIGHAND | CLONE_FS | CLONE_PIDFD,
|
memset(&clargs, 0, sizeof(clargs));
|
||||||
.pidfd = (uintptr_t)pidfd,
|
clargs.pidfd = (uintptr_t)pidfd;
|
||||||
.child_tid = 0,
|
clargs.flags = CLONE_CLEAR_SIGHAND | CLONE_FS | CLONE_PIDFD;
|
||||||
.parent_tid = 0,
|
clargs.exit_signal = SIGCHLD; // FIXME maybe switch it up for doctest?
|
||||||
.exit_signal = SIGCHLD, // FIXME maybe switch it up for doctest?
|
|
||||||
.stack = 0, // automatically created by clone3()
|
|
||||||
.stack_size = 0, // automatically set by clone3()
|
|
||||||
.tls = 0,
|
|
||||||
.set_tid = 0,
|
|
||||||
.set_tid_size = 0,
|
|
||||||
};
|
|
||||||
pid_t p = syscall(__NR_clone3, &clargs, sizeof(clargs));
|
pid_t p = syscall(__NR_clone3, &clargs, sizeof(clargs));
|
||||||
if(p == 0){
|
if(p == 0){
|
||||||
if(dup2(pipes[1], STDOUT_FILENO) < 0 || dup2(pipes[1], STDERR_FILENO) < 0){
|
if(dup2(pipes[1], STDOUT_FILENO) < 0 || dup2(pipes[1], STDERR_FILENO) < 0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user