waitpid(2) now returns ECHILD on error.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-01 14:54:19 +01:00
parent cf53e4a020
commit 6562da4092
3 changed files with 12 additions and 5 deletions

View File

@ -21,5 +21,6 @@
#define EACCESS 29
#define ESRCH 30
#define ENOTTY 31
#define ECHILD 32
#endif

View File

@ -24,21 +24,26 @@
#include "platform.h"
#include "error.h"
#ifndef SORTIX_KERNEL
#include "syscall.h"
#include <stdio.h>
#endif
namespace Maxsi
{
namespace Error
{
DEFN_SYSCALL1(int, SysRegisterErrno, 28, int*);
extern "C" { int errno = 0; }
#ifndef SORTIX_KERNEL
DEFN_SYSCALL1(int, SysRegisterErrno, 28, int*);
extern "C" void init_error_functions()
{
errno = 0;
SysRegisterErrno(&errno);
}
#endif
extern "C" char* strerror(int code)
{
@ -64,6 +69,7 @@ namespace Maxsi
case EACCESS: return (char*) "Permission denied";
case ESRCH: return (char*) "No such process";
case ENOTTY: return (char*) "Not a tty";
case ECHILD: return (char*) "No child processes";
default: return (char*) "Unknown error condition";
}
}

View File

@ -635,8 +635,8 @@ namespace Sortix
if ( pid != -1 )
{
Process* waitingfor = Process::Get(pid);
if ( !waitingfor ) { return -1; /* TODO: ECHILD*/ }
if ( waitingfor->parent != process ) { return -1; /* TODO: ECHILD*/ }
if ( !waitingfor ) { Error::Set(ECHILD); return -1; }
if ( waitingfor->parent != process ) { Error::Set(ECHILD); return -1; }
}
// 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
// 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.
thread->onchildprocessexit = SysWaitCallback;