Changeset 1633
- Timestamp:
- Nov 15, 2004, 9:21:54 AM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/signal.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1632 r1633 3 3 * @changed bird: Added sighold(), sigignore(), sigrelse(). Added wrapper 4 4 * between the two sigpause() APIs. 5 * @changed bird: include sys/timespec.h. 5 6 */ 6 7 … … 47 48 #include <sys/_types.h> 48 49 #include <sys/signal.h> 50 #include <sys/timespec.h> /* bird: Need full timespec declaration. */ 49 51 50 52 #if __BSD_VISIBLE -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/sigtimedwait.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1632 r1633 65 65 siginfo_t SigInfo; 66 66 int rc = __libc_Back_signalWait(pSigSet, &SigInfo, pTimeout); 67 if ( !rc)67 if (rc >= 0) 68 68 { 69 69 if (pSigInfo) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/sigwait.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1632 r1633 60 60 if (piSignalNo) 61 61 *piSignalNo = SigInfo.si_signo; 62 if (rc > 0) 63 rc = 0; 62 64 63 65 LIBCLOG_RETURN_MSG(rc, "ret rc (*piSignalNo=%d)\n", SigInfo.si_signo); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_signalSuspend.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1632 r1633 76 76 */ 77 77 rc = __libc_back_signalWait(pThrd, &SigSuspend.fDone, NULL); 78 if (rc != EAGAIN) 79 __libc_back_signalSemRelease(); 78 __libc_back_signalSemRelease(); 80 79 LIBCLOG_RETURN_INT(rc); 81 80 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_signalWait.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1632 r1633 100 100 sigset_t SigSetPending; 101 101 __SIGSET_OR(&SigSetPending, &pThrd->SigSetPending, &__libc_gSignalPending); 102 __SIGSET_AND(&SigSetPending, & pThrd->SigSetPending, &SigSet);102 __SIGSET_AND(&SigSetPending, &SigSetPending, &SigSet); 103 103 if (!__SIGSET_ISEMPTY(&SigSetPending)) 104 104 { … … 133 133 * Wait till state changes back and then return according to the wait result. 134 134 * 135 * The result is a bit tricky. EAGAIN means time out and no semaphore. While 136 * EINTR means that we've been interrupted by the delivery of a signal, which 137 * might mean that we got what we waited for or that some other signal was 138 * delivered to this thread. Very simple. :-) 135 * EAGAIN means time out. While EINTR means that we've been interrupted by 136 * the delivery of a signal, which might mean that we got what we waited 137 * for or that some other signal was delivered to this thread. Very simple. :-) 139 138 */ 140 139 rc = __libc_back_signalWait(pThrd, &SigWait.fDone, pTimeout ? &Timeout : NULL); 141 if (rc != -EAGAIN)142 140 pThrd->enmStatus = enmLIBCThreadStatus_unknown; 141 __libc_back_signalSemRelease(); 143 142 if (rc == -EINTR) 144 143 { … … 151 150 } 152 151 152 153 153 LIBCLOG_RETURN_MSG(rc, "ret %d SigWait.SigInfo={si_signo=%d, si_errno=%d, si_code=%#x, si_timestamp=%#x, si_flags=%#x, si_pid=%d, si_tid=%d, si_uid=%d, si_status=%d, si_addr=%p, si_value=%#08x, si_band=%ld}\n", 154 154 rc, SigWait.SigInfo.si_signo, SigWait.SigInfo.si_errno, SigWait.SigInfo.si_code, SigWait.SigInfo.si_timestamp, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sharedpm.c
-
Property cvs2svn:cvs-rev
changed from
1.22
to1.23
r1632 r1633 804 804 */ 805 805 int rc = spmRequestMutex(&RegRec); 806 if ( !rc)806 if (rc) 807 807 LIBCLOG_RETURN_INT(rc); 808 808 … … 851 851 */ 852 852 int rc = spmRequestMutex(&RegRec); 853 if ( !rc)853 if (rc) 854 854 LIBCLOG_RETURN_INT(rc); 855 855 … … 895 895 */ 896 896 int rc = spmRequestMutex(&RegRec); 897 if ( !rc)897 if (rc) 898 898 LIBCLOG_RETURN_INT(rc); 899 899 … … 943 943 */ 944 944 int rc = spmRequestMutex(&RegRec); 945 if ( !rc)945 if (rc) 946 946 LIBCLOG_RETURN_INT(rc); 947 947 … … 1007 1007 if (!rc) 1008 1008 LIBCLOG_RETURN_INT(0); 1009 errno = rc;1009 errno = -rc; 1010 1010 LIBCLOG_RETURN_INT(-1); 1011 1011 } … … 1413 1413 for (; pProcess; pProcess = pProcess->pNext) 1414 1414 { 1415 if ( pProcess->pgrp != pgrp1416 && !pProcess->fExeInited)1415 if ( pProcess->pgrp == pgrp 1416 && pProcess->fExeInited) 1417 1417 { 1418 1418 /* try queue the signal */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/signals.c
-
Property cvs2svn:cvs-rev
changed from
1.12
to1.13
r1632 r1633 1761 1761 ) 1762 1762 { 1763 pThrd->u.pSigSuspend->fDone = 1; 1764 pThrd->u.pSigSuspend = NULL; 1765 pThrd->enmStatus = enmLIBCThreadStatus_sigsuspend; 1763 if (pThrd->u.pSigSuspend) 1764 { 1765 pThrd->u.pSigSuspend->fDone = 1; 1766 pThrd->u.pSigSuspend = NULL; 1767 } 1768 pThrd->enmStatus = enmLIBCThreadStatus_unknown; 1766 1769 } 1767 1770 … … 1941 1944 /* 1942 1945 * Re-take the signal semaphore and restore the signal mask. 1946 * We'll have to reschedule signals here unless the two masks are 100% equal 1943 1947 */ 1944 1948 if (__libc_back_signalSemRequest()) 1945 1949 break; 1946 1950 pThrd->SigSetBlocked = SigSetOld; 1951 signalScheduleSPM(pThrd); 1952 signalScheduleProcess(pThrd); 1947 1953 } 1948 1954 … … 2134 2140 * Wait for interruption (outside semaphores of course). 2135 2141 */ 2142 DosSleep(0); /** @todo rewrite to call the signalWait worker and change the thread state while here! */ 2136 2143 __libc_back_signalSemRelease(); 2137 DosWaitEventSem(__libc_back_ghevWait, SEM_INDEFINITE_WAIT); 2144 int rc; 2145 do rc = DosWaitEventSem(__libc_back_ghevWait, 24*3600*1000); while (rc == ERROR_SEM_TIMEOUT || rc == ERROR_TIMEOUT); 2138 2146 return __libc_back_signalSemRequest(); 2139 2147 } … … 2222 2230 /* 2223 2231 * Check that the process exists first. 2224 */ 2232 * Only root users are allowed to do this. (Mainly to fix some testcases :-) 2233 */ 2234 if (__libc_spmGetId(__LIBC_SPMID_EUID)) 2235 LIBCLOG_RETURN_MSG(-EPERM, "%d (Only root can signal OS/2 processes.) euid=%d\n", -EPERM, __libc_spmGetId(__LIBC_SPMID_EUID)); 2225 2236 FS_SAVE_LOAD(); 2226 2237 rc = DosVerifyPidTid(pid, 1); … … 2373 2384 if (SigInfo.si_pid) 2374 2385 SigInfo.si_pid = _sys_pid; 2375 __LIBC_PTHREAD pThrd = __libc_threadCurrent NoAuto();2386 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 2376 2387 if (pThrd) 2377 2388 SigInfo.si_tid = pThrd->tid; … … 2392 2403 */ 2393 2404 rc = __libc_spmSigQueuePGrp(iSignalNo, &SigInfo, pgrp, SigInfo.si_flags & __LIBC_SI_QUEUED, signalSendPGrpCallback, NULL); 2405 2406 /* 2407 * Just in case the signal were for our selves too, we'll do the 2408 * schedule & deliver stuff. 2409 */ 2410 signalScheduleSPM(pThrd); 2411 signalScheduleProcess(pThrd); 2412 signalDeliver(pThrd, 0, NULL); 2394 2413 2395 2414 __libc_back_signalSemRelease(); … … 2947 2966 bzero(pSigInfo, sizeof(*pSigInfo)); 2948 2967 pSigInfo->si_signo = iSignalNo; 2968 pSigInfo->si_code = SI_USER; 2949 2969 } 2950 2970 } … … 2973 2993 * Calc wait period. 2974 2994 */ 2975 ULONG cMillies = SEM_INDEFINITE_WAIT;2995 ULONG cMillies = 30*1000; 2976 2996 if (pTimeout) 2977 2997 { 2978 cMillies = pTimeout->tv_nsec * 1000 + pTimeout->tv_sec / 1000; 2979 if (!cMillies && pTimeout->tv_sec) 2998 if (pTimeout->tv_nsec >= 100000000 || pTimeout->tv_nsec < 0) 2999 { 3000 LIBC_ASSERTM_FAILED("Invalid tv_nsec! tv_sec=%d tv_nsec=%ld\n", pTimeout->tv_sec, pTimeout->tv_nsec); 3001 LIBCLOG_RETURN_INT(-EINVAL); 3002 } 3003 if ( pTimeout->tv_sec < 0 3004 || pTimeout->tv_sec >= 4294967) 3005 { 3006 LIBC_ASSERTM_FAILED("Invalid tv_sec! tv_sec=%d (max=4294967) tv_nsec=%ld\n", pTimeout->tv_sec, pTimeout->tv_nsec); 3007 LIBCLOG_RETURN_INT(-EINVAL); 3008 } 3009 3010 cMillies = pTimeout->tv_sec * 1000 + pTimeout->tv_nsec / 1000000; 3011 if (!cMillies && pTimeout->tv_nsec) 2980 3012 cMillies = 1; 2981 3013 } 2982 3014 2983 3015 /* 2984 * Wait for interruption (outside semaphores of course). 2985 */ 3016 * Wait for interruption. 3017 */ 3018 int rc = 0; 2986 3019 FS_VAR(); 2987 3020 FS_SAVE_LOAD(); 2988 3021 ULONG ulStart = 0; 2989 3022 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulStart, sizeof(ulStart)); 2990 __libc_back_signalSemRelease();2991 3023 for (;;) 2992 3024 { 2993 int rc = DosWaitEventSem(__libc_back_ghevWait, cMillies); 3025 /* 3026 * Release the semaphore and recheck exit condition before 3027 * engaging in waiting again. 3028 */ 3029 DosSleep(0); /** @todo need better methods for waiting! */ 3030 __libc_back_signalSemRelease(); 3031 if (*pfDone) 3032 { 3033 rc = -EINTR; 3034 break; 3035 } 3036 rc = DosWaitEventSem(__libc_back_ghevWait, cMillies); 2994 3037 2995 3038 /* 2996 3039 * We returned from the wait, but did we do so for the right reason? 2997 3040 */ 2998 if (rc == ERROR_TIMEOUT || rc == ERROR_SEM_TIMEOUT) 2999 { 3000 FS_RESTORE(); 3001 LIBCLOG_RETURN_INT(-EAGAIN); 3002 } 3003 rc = __libc_back_signalSemRequest(); 3004 if (*pfDone) 3005 { 3006 FS_RESTORE(); 3007 LIBCLOG_RETURN_INT(-EINTR); 3008 } 3041 if (__libc_back_signalSemRequest()) 3042 rc = -EDEADLK; 3043 else if (*pfDone) 3044 rc = -EINTR; 3045 else if (pTimeout && (rc == ERROR_TIMEOUT || rc == ERROR_SEM_TIMEOUT)) 3046 rc = -EAGAIN; 3047 if (rc < 0) 3048 break; 3009 3049 3010 3050 /* 3011 3051 * Resume waiting. 3012 3052 */ 3013 if ( cMillies != SEM_INDEFINITE_WAIT)3053 if (pTimeout) 3014 3054 { 3015 3055 ULONG ulEnd = 0; … … 3023 3063 } 3024 3064 } /* for ever */ 3065 3066 FS_RESTORE(); 3067 LIBCLOG_RETURN_INT(rc); 3025 3068 } 3026 3069 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.