diff --git a/libmaxsi/decl/errno_values.h b/libmaxsi/decl/errno_values.h index a8bf3095..4e435ff2 100644 --- a/libmaxsi/decl/errno_values.h +++ b/libmaxsi/decl/errno_values.h @@ -21,5 +21,6 @@ #define EACCESS 29 #define ESRCH 30 #define ENOTTY 31 +#define ECHILD 32 #endif diff --git a/libmaxsi/error.cpp b/libmaxsi/error.cpp index 999ccac4..49faec2c 100644 --- a/libmaxsi/error.cpp +++ b/libmaxsi/error.cpp @@ -24,21 +24,26 @@ #include "platform.h" #include "error.h" +#ifndef SORTIX_KERNEL #include "syscall.h" +#include +#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"; } } diff --git a/sortix/process.cpp b/sortix/process.cpp index e4d6952a..31362d88 100644 --- a/sortix/process.cpp +++ b/sortix/process.cpp @@ -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;