Add wait4 syscall to Noux, just blocking for now
This commit is contained in:
parent
0bf0b31c54
commit
18d0b316d4
|
@ -48,6 +48,7 @@ namespace Noux {
|
||||||
SYSCALL_SELECT,
|
SYSCALL_SELECT,
|
||||||
SYSCALL_FORK,
|
SYSCALL_FORK,
|
||||||
SYSCALL_GETPID,
|
SYSCALL_GETPID,
|
||||||
|
SYSCALL_WAIT4,
|
||||||
SYSCALL_INVALID = -1
|
SYSCALL_INVALID = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ namespace Noux {
|
||||||
NOUX_DECL_SYSCALL_NAME(SELECT)
|
NOUX_DECL_SYSCALL_NAME(SELECT)
|
||||||
NOUX_DECL_SYSCALL_NAME(FORK)
|
NOUX_DECL_SYSCALL_NAME(FORK)
|
||||||
NOUX_DECL_SYSCALL_NAME(GETPID)
|
NOUX_DECL_SYSCALL_NAME(GETPID)
|
||||||
|
NOUX_DECL_SYSCALL_NAME(WAIT4)
|
||||||
case SYSCALL_INVALID: return 0;
|
case SYSCALL_INVALID: return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -253,6 +253,9 @@ namespace Noux {
|
||||||
{ int pid; });
|
{ int pid; });
|
||||||
|
|
||||||
SYSIO_DECL(getpid, { }, { int pid; });
|
SYSIO_DECL(getpid, { }, { int pid; });
|
||||||
|
|
||||||
|
SYSIO_DECL(wait4, { int pid; bool nohang; },
|
||||||
|
{ int pid; int status; });
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -380,19 +380,17 @@ extern "C" pid_t getpid(void)
|
||||||
extern "C" pid_t _wait4(pid_t pid, int *status, int options,
|
extern "C" pid_t _wait4(pid_t pid, int *status, int options,
|
||||||
struct rusage *rusage)
|
struct rusage *rusage)
|
||||||
{
|
{
|
||||||
/*
|
sysio()->wait4_in.pid = pid;
|
||||||
* XXX dummy to accomodate the 'reap_zombie_children' function in bash
|
sysio()->wait4_in.nohang = !!(options & WNOHANG);
|
||||||
*/
|
if (!noux()->syscall(Noux::Session::SYSCALL_WAIT4)) {
|
||||||
if (options & WNOHANG) {
|
PERR("wait4 error %d", sysio()->error.general);
|
||||||
PWRN("_wait4 dummy called (with WNOHANG) - not implemented");
|
return -1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PDBG("_wait4 (pid=%d, options=0x%x) called, waiting forever...",
|
if (status)
|
||||||
pid, options);
|
*status = sysio()->wait4_out.status;
|
||||||
|
|
||||||
for (;;);
|
return sysio()->wait4_out.pid;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,24 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case SYSCALL_WAIT4:
|
||||||
|
{
|
||||||
|
PINF("SYSCALL_WAIT4 called");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX check if one of out children exited
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!_sysio->wait4_in.nohang)
|
||||||
|
_blocker.down();
|
||||||
|
|
||||||
|
_sysio->wait4_out.pid = -1;
|
||||||
|
_sysio->wait4_out.status = 0;
|
||||||
|
|
||||||
|
PINF("SYSCALL_WAIT4 returning");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case SYSCALL_INVALID: break;
|
case SYSCALL_INVALID: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue