mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix waitpid status copying to user-space.
This commit is contained in:
parent
24d8725a3e
commit
cef4c8d982
1 changed files with 10 additions and 5 deletions
|
@ -457,10 +457,11 @@ void Process::NotifyNewZombies()
|
||||||
kthread_cond_broadcast(&zombiecond);
|
kthread_cond_broadcast(&zombiecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t Process::Wait(pid_t thepid, int* user_status, int options)
|
pid_t Process::Wait(pid_t thepid, int* status_ptr, int options)
|
||||||
{
|
{
|
||||||
// TODO: Process groups are not supported yet.
|
// TODO: Process groups are not supported yet.
|
||||||
if ( thepid < -1 || thepid == 0 ) { errno = ENOSYS; return -1; }
|
if ( thepid < -1 || thepid == 0 )
|
||||||
|
return errno = ENOSYS, -1;
|
||||||
|
|
||||||
ScopedLock lock(&childlock);
|
ScopedLock lock(&childlock);
|
||||||
|
|
||||||
|
@ -530,15 +531,19 @@ pid_t Process::Wait(pid_t thepid, int* user_status, int options)
|
||||||
if ( !in_limbo )
|
if ( !in_limbo )
|
||||||
delete zombie;
|
delete zombie;
|
||||||
|
|
||||||
if ( user_status && !CopyToUser(user_status, &status, sizeof(status)) )
|
if ( status_ptr )
|
||||||
return -1;
|
*status_ptr = status;
|
||||||
|
|
||||||
return thepid;
|
return thepid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pid_t sys_waitpid(pid_t pid, int* user_status, int options)
|
static pid_t sys_waitpid(pid_t pid, int* user_status, int options)
|
||||||
{
|
{
|
||||||
return CurrentProcess()->Wait(pid, user_status, options);
|
int status = 0;
|
||||||
|
pid_t ret = CurrentProcess()->Wait(pid, &status, options);
|
||||||
|
if ( 0 < ret && !CopyToUser(user_status, &status, sizeof(status)) )
|
||||||
|
return -1;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::ExitThroughSignal(int signal)
|
void Process::ExitThroughSignal(int signal)
|
||||||
|
|
Loading…
Reference in a new issue