mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
waitpid(2) now returns ECHILD on error.
This commit is contained in:
parent
cf53e4a020
commit
6562da4092
3 changed files with 12 additions and 5 deletions
|
@ -21,5 +21,6 @@
|
||||||
#define EACCESS 29
|
#define EACCESS 29
|
||||||
#define ESRCH 30
|
#define ESRCH 30
|
||||||
#define ENOTTY 31
|
#define ENOTTY 31
|
||||||
|
#define ECHILD 32
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,21 +24,26 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#ifndef SORTIX_KERNEL
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Maxsi
|
namespace Maxsi
|
||||||
{
|
{
|
||||||
namespace Error
|
namespace Error
|
||||||
{
|
{
|
||||||
DEFN_SYSCALL1(int, SysRegisterErrno, 28, int*);
|
|
||||||
|
|
||||||
extern "C" { int errno = 0; }
|
extern "C" { int errno = 0; }
|
||||||
|
|
||||||
|
#ifndef SORTIX_KERNEL
|
||||||
|
DEFN_SYSCALL1(int, SysRegisterErrno, 28, int*);
|
||||||
|
|
||||||
extern "C" void init_error_functions()
|
extern "C" void init_error_functions()
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
SysRegisterErrno(&errno);
|
SysRegisterErrno(&errno);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" char* strerror(int code)
|
extern "C" char* strerror(int code)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +69,7 @@ namespace Maxsi
|
||||||
case EACCESS: return (char*) "Permission denied";
|
case EACCESS: return (char*) "Permission denied";
|
||||||
case ESRCH: return (char*) "No such process";
|
case ESRCH: return (char*) "No such process";
|
||||||
case ENOTTY: return (char*) "Not a tty";
|
case ENOTTY: return (char*) "Not a tty";
|
||||||
|
case ECHILD: return (char*) "No child processes";
|
||||||
default: return (char*) "Unknown error condition";
|
default: return (char*) "Unknown error condition";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,8 +635,8 @@ namespace Sortix
|
||||||
if ( pid != -1 )
|
if ( pid != -1 )
|
||||||
{
|
{
|
||||||
Process* waitingfor = Process::Get(pid);
|
Process* waitingfor = Process::Get(pid);
|
||||||
if ( !waitingfor ) { return -1; /* TODO: ECHILD*/ }
|
if ( !waitingfor ) { Error::Set(ECHILD); return -1; }
|
||||||
if ( waitingfor->parent != process ) { return -1; /* TODO: ECHILD*/ }
|
if ( waitingfor->parent != process ) { Error::Set(ECHILD); return -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find any zombie children matching the search description.
|
// Find any zombie children matching the search description.
|
||||||
|
@ -667,7 +667,7 @@ namespace Sortix
|
||||||
|
|
||||||
// The process needs to have children, otherwise we are waiting for
|
// The process needs to have children, otherwise we are waiting for
|
||||||
// nothing to happen.
|
// nothing to happen.
|
||||||
if ( !process->firstchild ) { return -1; /* TODO: ECHILD*/ }
|
if ( !process->firstchild ) { Error::Set(ECHILD); return -1; }
|
||||||
|
|
||||||
// Resumes this system call when the wait condition has been met.
|
// Resumes this system call when the wait condition has been met.
|
||||||
thread->onchildprocessexit = SysWaitCallback;
|
thread->onchildprocessexit = SysWaitCallback;
|
||||||
|
|
Loading…
Add table
Reference in a new issue