mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
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_FORK,
|
||||
SYSCALL_GETPID,
|
||||
SYSCALL_WAIT4,
|
||||
SYSCALL_INVALID = -1
|
||||
};
|
||||
|
||||
@ -70,6 +71,7 @@ namespace Noux {
|
||||
NOUX_DECL_SYSCALL_NAME(SELECT)
|
||||
NOUX_DECL_SYSCALL_NAME(FORK)
|
||||
NOUX_DECL_SYSCALL_NAME(GETPID)
|
||||
NOUX_DECL_SYSCALL_NAME(WAIT4)
|
||||
case SYSCALL_INVALID: return 0;
|
||||
}
|
||||
return 0;
|
||||
|
@ -253,6 +253,9 @@ namespace Noux {
|
||||
{ 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,
|
||||
struct rusage *rusage)
|
||||
{
|
||||
/*
|
||||
* XXX dummy to accomodate the 'reap_zombie_children' function in bash
|
||||
*/
|
||||
if (options & WNOHANG) {
|
||||
PWRN("_wait4 dummy called (with WNOHANG) - not implemented");
|
||||
return 0;
|
||||
sysio()->wait4_in.pid = pid;
|
||||
sysio()->wait4_in.nohang = !!(options & WNOHANG);
|
||||
if (!noux()->syscall(Noux::Session::SYSCALL_WAIT4)) {
|
||||
PERR("wait4 error %d", sysio()->error.general);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PDBG("_wait4 (pid=%d, options=0x%x) called, waiting forever...",
|
||||
pid, options);
|
||||
if (status)
|
||||
*status = sysio()->wait4_out.status;
|
||||
|
||||
for (;;);
|
||||
return 0;
|
||||
return sysio()->wait4_out.pid;
|
||||
}
|
||||
|
||||
|
||||
|
@ -323,6 +323,24 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user