- Timestamp:
- Dec 9, 2004, 9:19:34 AM (21 years ago)
- Location:
- trunk/src/emx/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/process/wait.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1722 r1723 50 50 * Just pass it along to waitpid. 51 51 */ 52 pid_t pid = wait pid(-1, piStatus, 0);52 pid_t pid = wait4(-1, piStatus, 0, NULL); 53 53 if (pid > 0) 54 54 LIBCLOG_RETURN_MSG(pid, "ret %d (%#x) iStatus=%#x\n", pid, pid, piStatus ? *piStatus : -1); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/wait4.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1722 r1723 2 2 /** @file 3 3 * 4 * LIBC - wait 3().4 * LIBC - wait4(). 5 5 * 6 6 * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de> … … 62 62 { 63 63 LIBC_ASSERTM_FAILED("pRUsage=%p - not implemented\n", (void *)pRUsage); 64 errno = ENOSYS; 64 /* errno = ENOSYS; 65 LIBCLOG_RETURN_INT(-1); */ 66 } 67 if (fOptions & ~(WEXITED | WUNTRACED | WSTOPPED | WCONTINUED | WNOHANG | WNOWAIT)) 68 { 69 LIBC_ASSERTM_FAILED("Unknown options %#x. (fOptions=%#x)\n", 70 fOptions & ~(WEXITED | WUNTRACED | WSTOPPED | WCONTINUED | WNOHANG | WNOWAIT), fOptions); 71 errno = EINVAL; 65 72 LIBCLOG_RETURN_INT(-1); 66 73 } 67 74 68 75 /* 69 * Let waitpid do the job.76 * Call waitid to do the actual waiting. 70 77 */ 71 pid = waitpid(pid, piStatus, fOptions); 78 /* convert pid to enmIdType and Id. */ 79 id_t Id; 80 idtype_t enmIdType; 72 81 if (pid > 0) 73 LIBCLOG_RETURN_MSG(pid, "ret %d (%#x) iStatus=%#x\n", pid, pid, piStatus ? *piStatus : -1); 74 LIBCLOG_RETURN_INT(pid); 82 { 83 enmIdType = P_PID; 84 Id = pid; 85 } 86 else if (pid == 0) 87 { 88 enmIdType = P_PGID; 89 Id = 0; 90 } 91 else if (pid == -1) 92 { 93 enmIdType = P_ALL; 94 Id = 0; 95 } 96 else 97 { 98 Id = -pid; 99 enmIdType = P_PGID; 100 } 101 102 /* do the call */ 103 siginfo_t SigInfo = {0}; 104 int rc = __libc_Back_processWait(enmIdType, Id, &SigInfo, fOptions | WEXITED, pRUsage); 105 if (!rc) 106 { 107 /* 108 * Convert signal info to status code. 109 */ 110 int iStatus; 111 switch (SigInfo.si_code) 112 { 113 default: 114 LIBC_ASSERTM_FAILED("Invalid si_code=%d\n", SigInfo.si_code); 115 case CLD_EXITED: iStatus = W_EXITCODE(SigInfo.si_status, 0); break; 116 case CLD_KILLED: iStatus = W_EXITCODE(0, SigInfo.si_status); break; 117 case CLD_DUMPED: iStatus = W_EXITCODE(0, SigInfo.si_status) | WCOREFLAG; break; 118 case CLD_TRAPPED: iStatus = W_STOPCODE(SigInfo.si_status); break; 119 case CLD_STOPPED: iStatus = W_STOPCODE(SigInfo.si_status); break; 120 case CLD_CONTINUED: iStatus = W_STOPCODE(SigInfo.si_status); break; 121 122 } 123 if (piStatus) 124 *piStatus = iStatus; 125 LIBCLOG_RETURN_MSG(SigInfo.si_pid, "ret %d (%#x) iStatus=%#x\n", 126 SigInfo.si_pid, SigInfo.si_pid, iStatus); 127 } 128 129 /* 130 * wait4() doesn't return EINVAL for anything but invalid fOptions 131 * and since we've already validated those, they cannot be the cause 132 * of EINVAL. 133 */ 134 if (rc == -EINVAL) 135 rc = -ECHILD; 136 errno = -rc; 137 LIBCLOG_RETURN_INT((pid_t)-1); 75 138 } 76 139 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/waitid.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1722 r1723 42 42 * @returns 0 on success, pSigInfo containing status info. 43 43 * @returns -1 and errno on failure. 44 * ECHILD is returned as specfied for waitpid() in SuS. The waitid() errno specs 45 * are very short and doesn't explain what they mean by "idtype and id specify an 46 * invalid set of processes". 44 47 * @param enmIdType What kind of process specification Id contains. 45 48 * @param Id Process specification of the enmIdType sort. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/waitpid.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1722 r1723 54 54 { 55 55 LIBCLOG_ENTER("pid=%#x (%d) piStatus=%p fOptions=%#x\n", pid, pid, (void *)piStatus, fOptions); 56 57 56 /* 58 * Call waitid to do the actual waiting.57 * Let wait4 do the job. 59 58 */ 60 /* convert pid to enmIdType and Id. */ 61 id_t Id; 62 idtype_t enmIdType; 59 pid = wait4(pid, piStatus, fOptions, NULL); 63 60 if (pid > 0) 64 { 65 enmIdType = P_PID; 66 Id = pid; 67 } 68 else if (pid == 0) 69 { 70 enmIdType = P_PGID; 71 Id = 0; 72 } 73 else if (pid == -1) 74 { 75 enmIdType = P_ALL; 76 Id = 0; 77 } 78 else 79 { 80 Id = -pid; 81 enmIdType = P_PGID; 82 } 83 84 /* do the call */ 85 siginfo_t SigInfo = {0}; 86 int rc = waitid(P_ALL, 0, &SigInfo, fOptions | WEXITED); 87 if (!rc) 88 { 89 /* 90 * Convert signal info to status code. 91 */ 92 int iStatus; 93 switch (SigInfo.si_code) 94 { 95 default: 96 LIBC_ASSERTM_FAILED("Invalid si_code=%d\n", SigInfo.si_code); 97 case CLD_EXITED: iStatus = W_EXITCODE(SigInfo.si_status, 0); break; 98 case CLD_KILLED: iStatus = W_EXITCODE(0, SigInfo.si_status); break; 99 case CLD_DUMPED: iStatus = W_EXITCODE(0, SigInfo.si_status) | WCOREFLAG; break; 100 case CLD_TRAPPED: iStatus = W_STOPCODE(SigInfo.si_status); break; 101 case CLD_STOPPED: iStatus = W_STOPCODE(SigInfo.si_status); break; 102 case CLD_CONTINUED: iStatus = W_STOPCODE(SigInfo.si_status); break; 103 104 } 105 if (piStatus) 106 *piStatus = iStatus; 107 LIBCLOG_RETURN_MSG(SigInfo.si_pid, "ret %d (%#x) iStatus=%#x\n", 108 SigInfo.si_pid, SigInfo.si_pid, iStatus); 109 } 110 LIBCLOG_RETURN_INT(rc); 61 LIBCLOG_RETURN_MSG(pid, "ret %d (%#x) iStatus=%#x\n", pid, pid, piStatus ? *piStatus : -1); 62 LIBCLOG_RETURN_INT(-1); 111 63 } 112 64 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_processWait.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1722 r1723 736 736 { 737 737 case P_ALL: 738 break; 738 739 case P_PID: 740 if (Id <= 0 || Id >= 0x7fffffff) 741 { 742 LIBC_ASSERTM_FAILED("Invalid P_PID Id %lld\n", Id); 743 LIBCLOG_RETURN_INT(-EINVAL); 744 } 745 break; 739 746 case P_PGID: 747 if (Id < 0 || Id >= 0x7fffffff) 748 { 749 LIBC_ASSERTM_FAILED("Invalid P_PGID Id %lld\n", Id); 750 LIBCLOG_RETURN_INT(-EINVAL); 751 } 740 752 break; 741 753 default: … … 803 815 if (fFlag && (fFlag & fOptions)) 804 816 { 805 if ( enmIdType == P_ALL 806 || (enmIdType == P_PID && pInfo->pid == pid) 807 || (enmIdType == P_PGID && pInfo->pgrp == pid)) 817 if (enmIdType == P_ALL) 818 break; 819 else if (enmIdType == P_PID) 820 { 821 if (pInfo->pid == pid) 822 break; 823 } 824 else if (enmIdType == P_PGID && pInfo->pgrp == pid) 808 825 break; 809 826 } … … 885 902 * Should call DosVerifyPidTid and DosGetPPid(). */ 886 903 waitSemRelease(); 887 rc = -ECHILD; /* this ain't correct!*/904 rc = -ECHILD; /* See discussion in this function description and in waitid(). */ 888 905 break; 889 906 } … … 894 911 if (rc) 895 912 { 913 rc = __libc_spmValidPGrp((pid_t)Id, 0 /* check for group existance */); 896 914 waitSemRelease(); 897 rc = -ECHILD; 915 rc = -ECHILD; /* See discussion in this function description and in waitid(). */ 898 916 break; 899 917 } 900 918 } 901 919 waitSemRelease(); 920 921 /* 922 * If non-blocking we must return now. 923 */ 924 if (fOptions & WNOHANG) 925 { 926 rc = 0; 927 break; 928 } 902 929 903 930 /* -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.