# Patch created by ioman # Date: Mi Mär 2 15:19:56 CET 2005 # Repository: pnet # Comments: # # # Added functions _IL_Process_GetErrnoMessage _IL_Process_GetErrno to get the result of forked processes. # V2: fork() modified to return errno result. #### End of Preamble #### #### Patch data follows #### Index: engine/lib_task.c =================================================================== RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_task.c,v retrieving revision 1.11 diff -c -r1.11 lib_task.c *** engine/lib_task.c 1 Nov 2003 03:04:03 -0000 1.11 --- engine/lib_task.c 2 Mar 2005 14:20:12 -0000 *************** *** 579,584 **** --- 579,585 ---- int pid; ILInt32 argc; const char *ansi; + int pipefds[2]; #define FreeStringList(list,size) \ do { \ if((list)) \ *************** *** 712,717 **** --- 713,724 ---- *stderrHandle = (ILNativeInt)(stderrFds[0]); } + /* Open the pipe for returning errno */ + if(pipe(pipefds) < 0) + { + return 0; + } + /* Fork and execute the process */ *processID = -1; *processHandle = 0; *************** *** 739,745 **** --- 746,758 ---- extern char **environ; environ = newEnviron; } + + #ifdef HAVE_FCNTL + fcntl(pipefds[1],F_SETFD,1); + #endif + execvp(fname, args); + write(pipefds[1],&errno, sizeof(errno)); exit(1); } else if(pid > 0) *************** *** 758,763 **** --- 771,779 ---- close(stderrFds[1]); } *processID = (ILInt32)pid; + close(pipefds[1]); + errno = 0; + read(pipefds[0],&errno,sizeof(errno)); result = 1; } else *************** *** 912,917 **** --- 928,956 ---- #endif } + /* + * public static Errno GetErrno(); + */ + ILInt32 _IL_Process_GetErrno(ILExecThread *thread) + { + return ILSysIOGetErrno(); + } + + /* + * public static String GetErrnoMessage(Errno error); + */ + ILString *_IL_Process_GetErrnoMessage(ILExecThread *thread, ILInt32 error) + { + const char *msg = ILSysIOGetErrnoMessage(error); + if(msg) + { + return ILStringCreate(thread, msg); + } + else + { + return 0; + } + } #ifdef __cplusplus }; #endif #### End of Patch data ####