Changeset 1618


Ignore:
Timestamp:
Nov 7, 2004, 3:19:42 PM (21 years ago)
Author:
bird
Message:

More signal debugging and cleanup.

Location:
trunk/src/emx
Files:
2 added
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/backend.h

    • Property cvs2svn:cvs-rev changed from 1.9 to 1.10
    r1617 r1618  
    560560 *
    561561 * @returns 0 on success.
    562  * @returns -Negative errno on failure.
     562 * @returns on failure.
    563563 * @param   iSignalNo   Signal number.
    564564 * @param   pSigAct     Pointer to new signal action.
     
    570570
    571571/**
     572
     573
     574
     575
     576
     577
     578
     579
     580
     581
     582
     583
     584
    572585 * Changes and/or queries the alternative signal stack settings of a thread.
    573586 *
     
    584597 *
    585598 * @returns 0 on success.
    586  * @returns -1 and errno set to EINVAL on failure.
     599 * @returns on failure.
    587600 * @param   pThrd       Thread to apply this to.
    588601 * @param   iHow        Describes the action taken if pSigSetNew not NULL. Recognized
     
    604617int __libc_Back_signalMask(__LIBC_PTHREAD pThrd, int iHow, const sigset_t * __restrict pSigSetNew, sigset_t * __restrict pSigSetOld);
    605618
     619
     620
     621
     622
     623
     624
     625
     626
     627
     628
     629
     630
     631
     632
     633
     634
     635
     636
     637
     638
     639
     640
     641
     642
     643
     644
     645
     646
     647
     648
     649
     650
     651
     652
     653
    606654/** @} */
    607655
  • trunk/src/emx/include/InnoTekLIBC/libc.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    2929
    3030#include <sys/cdefs.h>
     31
    3132
    3233__BEGIN_DECLS
     
    4142extern int __libc_gfNoUnix;
    4243
     44
     45
     46
     47
     48
     49
     50
    4351__END_DECLS
    4452
  • trunk/src/emx/include/InnoTekLIBC/thread.h

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1617 r1618  
    5050*******************************************************************************/
    5151struct _uheap;
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
    5276
    5377/**
     
    150174
    151175    /** Thread status, chiefly used for the u member of the thread structure. */
    152     enum enmLIBCThreadStatus
     176    enum enmLIBCThreadStatus
    153177    {
    154178        /** The thread status must be queried from the OS. */
     
    158182        /** The thread is in a sigwait(), sigwaitinfo(), or sigtimedwait() call. */
    159183        enmLIBCThreadStatus_sigwait,
     184
     185
    160186    }               enmStatus;
    161187
     
    166192    {
    167193        /** enmLIBCThreadStatus_startup:    Begin Thread Arguments. */
    168         struct __libc_thread_startup
     194        struct __libc_thread_startup
    169195        {
    170196            /** Thread argument. */
     
    175201
    176202        /** enmLIBCThreadStatus_sigwait:    Thread blocked in sigwait(), sigwaitinfo() or sigtimedwait(). */
    177         struct __libc_thread_sigwait
    178         {
    179             /** The signals we're waiting for. */
    180             sigset_t    SigSetWait;
    181             /** The where to return signal info. */
    182             siginfo_t  *pSigInfo;
    183         } SigWait;
     203        __LIBC_PTHREAD_SIGWAIT      pSigWait;
     204        /** enmLIBCThreadStatus_sigsuspend: Thread blocked in sigsuspend(). */
     205        __LIBC_PTHREAD_SIGSUSPEND   pSigSuspend;
    184206    } u;
    185207
     
    211233} __LIBC_THREAD;
    212234
     235
    213236#ifndef __LIBC_THREAD_DECLARED
    214237#define __LIBC_THREAD_DECLARED
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.75 to 1.76
    r1617 r1618  
    12391239    "___libc_Back_signalStack" @1261
    12401240    "___libc_Back_signalMask" @1262
     1241
     1242
     1243
     1244
  • trunk/src/emx/src/lib/process/_signal_os2.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include <signal.h>
    3232#include <errno.h>
    33 #include <InnoTekLIBC/signals.h>
     33#include <InnoTekLIBC/libc.h>
     34#include <InnoTekLIBC/backend.h>
    3435#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3536#include <InnoTekLIBC/logstrict.h>
     
    5455    {
    5556        LIBC_ASSERTM_FAILED("invalid signal number for SIG_ACK %d\n", iSignalNo);
     57
     58
     59
     60
     61
     62
    5663        LIBCLOG_RETURN_P(SIG_ERR);
    5764    }
     
    96103
    97104        /*
    98          * Gain exclusive access to the signal stuff.
    99          */
    100         if (__libc_back_signalSemRequest())
    101             LIBCLOG_RETURN_P(SIG_ERR);
    102 
    103         /*
    104105         * Do work.
    105106         */
    106107        if (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo))
    107108            SigAct.sa_flags |= SA_RESTART;
    108         rc = __libc_back_signalAction(iSignalNo, &SigAct, &SigActOld);
    109 
    110         /*
    111          * Release semaphore.
    112          */
    113         __libc_back_signalSemRelease();
     109        rc = __libc_Back_signalAction(iSignalNo, &SigAct, &SigActOld);
    114110
    115111        /*
     
    118114        if (!rc)
    119115            LIBCLOG_RETURN_P(SigActOld.__sigaction_u.__sa_handler);
     116
    120117    }
    121118    LIBCLOG_RETURN_P(SIG_ERR);
  • trunk/src/emx/src/lib/process/_signal_sysv.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include <signal.h>
    3232#include <errno.h>
    33 #include <InnoTekLIBC/signals.h>
     33#include <InnoTekLIBC/libc.h>
     34#include <InnoTekLIBC/backend.h>
    3435#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3536#include <InnoTekLIBC/logstrict.h>
     
    5960        LIBCLOG_RETURN_P(SIG_ERR);
    6061    }
     62
     63
     64
     65
     66
     67
    6168    if (!__SIGSET_SIG_VALID(iSignalNo))
    6269    {
     
    7481
    7582    /*
    76      * Gain exclusive access to the signal stuff.
    77      */
    78     if (__libc_back_signalSemRequest())
    79         LIBCLOG_RETURN_P(SIG_ERR);
    80 
    81     /*
    8283     * Change signal action.
    8384     */
    8485    if (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo))
    8586        SigAct.sa_flags |= SA_RESTART;
    86     rc = __libc_back_signalAction(iSignalNo, &SigAct, &SigActOld);
    87 
    88     /*
    89      * Release semaphore.
    90      */
    91     __libc_back_signalSemRelease();
    92 
    93     /*
    94      * Check for errors and return.
    95      */
    96     if (rc)
    97         LIBCLOG_RETURN_P(SIG_ERR);
    98     LIBCLOG_RETURN_P(SigActOld.__sigaction_u.__sa_handler);
     87    rc = __libc_Back_signalAction(iSignalNo, &SigAct, &SigActOld);
     88    if (!rc)
     89        LIBCLOG_RETURN_P(SigActOld.__sigaction_u.__sa_handler);
     90    errno = -rc;
     91    LIBCLOG_RETURN_P(SIG_ERR);
    9992}
    10093
  • trunk/src/emx/src/lib/process/bsd_signal.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include <signal.h>
    3232#include <errno.h>
    33 #include <InnoTekLIBC/signals.h>
     33#include <InnoTekLIBC/libc.h>
     34#include <InnoTekLIBC/backend.h>
    3435#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3536#include <InnoTekLIBC/logstrict.h>
     
    5960        LIBCLOG_RETURN_P(SIG_ERR);
    6061    }
     62
     63
     64
     65
     66
     67
    6168    if (!__SIGSET_SIG_VALID(iSignalNo))
    6269    {
     
    7582
    7683    /*
    77      * Gain exclusive access to the signal stuff.
    78      */
    79     if (__libc_back_signalSemRequest())
    80         LIBCLOG_RETURN_P(SIG_ERR);
    81 
    82     /*
    8384     * Change signal action.
    8485     */
    8586    if (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo))
    8687        SigAct.sa_flags |= SA_RESTART;
    87     rc = __libc_back_signalAction(iSignalNo, &SigAct, &SigActOld);
    88 
    89     /*
    90      * Release semaphore.
    91      */
    92     __libc_back_signalSemRelease();
    93 
    94     /*
    95      * Check for errors and return.
    96      */
    97     if (rc)
    98         LIBCLOG_RETURN_P(SIG_ERR);
    99     LIBCLOG_RETURN_P(SigActOld.__sigaction_u.__sa_handler);
     88    rc = __libc_Back_signalAction(iSignalNo, &SigAct, &SigActOld);
     89    if (!rc)
     90        LIBCLOG_RETURN_P(SigActOld.__sigaction_u.__sa_handler);
     91    errno = -rc;
     92    LIBCLOG_RETURN_P(SIG_ERR);
    10093}
    10194
  • trunk/src/emx/src/lib/process/killpg.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include <signal.h>
    3232#include <errno.h>
    33 #include <InnoTekLIBC/signals.h>
     33#include <InnoTekLIBC/.h>
    3434#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3535#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/pause.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1617 r1618  
    3030*******************************************************************************/
    3131#include "libc-alias.h"
     32
    3233#include <signal.h>
    3334#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    35 #include <InnoTekLIBC/thread.h>
    3635#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3736#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/raise.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1617 r1618  
    3232#include <signal.h>
    3333#include <process.h>
    34 #include <InnoTekLIBC/signals.h>
    3534#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3635#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigblock.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    35 #include <InnoTekLIBC/thread.h>
     33#include <InnoTekLIBC/backend.h>
    3634#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3735#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sighold.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3232#include <signal.h>
    3333#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    3534#include <InnoTekLIBC/thread.h>
     35
    3636#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3737#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigignore.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3232#include <signal.h>
    3333#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    3534#include <InnoTekLIBC/thread.h>
     35
    3636#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3737#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/siginterrupt.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3333#include <signal.h>
    3434#include <errno.h>
    35 #include <InnoTekLIBC/signals.h>
    36 #include <InnoTekLIBC/thread.h>
     35#include <InnoTekLIBC/backend.h>
    3736#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3837#include <InnoTekLIBC/logstrict.h>
     
    5251{
    5352    LIBCLOG_ENTER("iSignalNo=%d fFlag=%d\n", iSignalNo, fFlag);
    54     struct sigaction    SigAct = {{0}};
    55     int                 rc;
    56     int                 rc2 = 0;
    5753
    5854    /*
    59      * Validate.
     55     * .
    6056     */
    61     if (!__SIGSET_SIG_VALID(iSignalNo))
    62     {
    63         LIBC_ASSERTM_FAILED("Invalid signal no %d\n", iSignalNo);
    64         errno = EINVAL;
    65         LIBCLOG_RETURN_INT(-1);
    66     }
    67 
    68     /*
    69      * Gain exclusive access to the signal stuff.
    70      */
    71     if (__libc_back_signalSemRequest())
    72         LIBCLOG_RETURN_INT(-1);
    73 
    74     /*
    75      * Get the previous signal action.
    76      */
    77     rc = __libc_back_signalAction(iSignalNo, NULL, &SigAct);
     57    int rc = __libc_Back_signalInterrupt(iSignalNo, fFlag);
    7858    if (!rc)
    79     {
    80         if (fFlag)
    81         {   /* interrupt */
    82             SigAct.sa_flags &= ~SA_RESTART;
    83             __SIGSET_CLEAR(&__libc_gSignalRestartMask, iSignalNo);
    84         }
    85         else
    86         {   /* restart */
    87             SigAct.sa_flags |= SA_RESTART;
    88             __SIGSET_SET(&__libc_gSignalRestartMask, iSignalNo);
    89         }
    90         rc2 = __libc_back_signalAction(iSignalNo, &SigAct, NULL);
    91     }
    92 
    93     /*
    94      * Release semaphore.
    95      */
    96     __libc_back_signalSemRelease();
    97 
    98 
    99     /*
    100      * Check for failure and return.
    101      */
    102     LIBC_ASSERTM(!rc2, "Impossible!\n");
    103     if (rc || rc2)
    104         LIBCLOG_RETURN_INT(-1);
    105 
    106     LIBCLOG_RETURN_INT(0);
     59        LIBCLOG_RETURN_INT(0);
     60    errno = -rc;
     61    LIBCLOG_RETURN_INT(-1);
    10762}
  • trunk/src/emx/src/lib/process/siginterrupt_data.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    2929*******************************************************************************/
    3030#include "libc-alias.h"
    31 #include <InnoTekLIBC/signals.h>
     31#include <InnoTekLIBC/.h>
    3232
    3333
  • trunk/src/emx/src/lib/process/signal.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1617 r1618  
    3030#include "libc-alias.h"
    3131#include <signal.h>
    32 #include <InnoTekLIBC/signals.h>
     32#include <InnoTekLIBC/.h>
    3333#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3434#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigpause.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3434#include <signal.h>
    3535#include <errno.h>
    36 #include <InnoTekLIBC/signals.h>
    37 #include <InnoTekLIBC/thread.h>
     36#include <InnoTekLIBC/backend.h>
    3837#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3938#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigpause_bsd.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3232#include <signal.h>
    3333#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    35 #include <InnoTekLIBC/thread.h>
     34#include <InnoTekLIBC/backend.h>
    3635#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3736#include <InnoTekLIBC/logstrict.h>
     37
     38
     39
    3840
    3941
  • trunk/src/emx/src/lib/process/sigpending.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <InnoTekLIBC/signals.h>
    34 #include <InnoTekLIBC/thread.h>
     33#include <.h>
     34#include <InnoTekLIBC/d.h>
    3535#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3636#include <InnoTekLIBC/logstrict.h>
     
    4747{
    4848    LIBCLOG_ENTER("pSigSet=%p\n", (void *)pSigSet);
    49     __LIBC_THREAD  *pThrd = __libc_threadCurrent();
    50     sigset_t        SigSet;
    5149
    52     __SIGSET_EMPTY(&SigSet);            /* touch it! (paranoia) */
    53 
    54     /*
    55      * Gain exclusive access to the signal stuff.
    56      */
    57     if (__libc_back_signalSemRequest())
    58         LIBCLOG_RETURN_INT(-1);
    59 
    60     /*
    61      * Or the blocked and pending members for this thread.
    62      */
    63     __SIGSET_OR(&SigSet, &__libc_gSignalPending, &pThrd->SigSetPending);
    64     __SIGSET_AND(&SigSet, &pThrd->SigSetBlocked, &SigSet);
    65 
    66     /*
    67      * Release semaphore.
    68      */
    69     __libc_back_signalSemRelease();
    70 
    71     /*
    72      * Copy the set.
    73      */
    74     *pSigSet = SigSet;
    75 
    76     LIBCLOG_RETURN_MSG(0, "ret 0 (*pSigSet={%08lx %08lx})\n", SigSet.__bitmap[1], SigSet.__bitmap[0]);
     50    int rc = __libc_Back_signalPending(pSigSet);
     51    if (!rc)
     52        LIBCLOG_RETURN_MSG(0, "ret 0 (*pSigSet={%08lx %08lx})\n", pSigSet->__bitmap[1], pSigSet->__bitmap[0]);
     53    errno = -rc;
     54    LIBCLOG_RETURN_INT(-1);
    7755}
    7856
  • trunk/src/emx/src/lib/process/sigprocmask.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1617 r1618  
    8080        if (pSigSetOld)
    8181            *pSigSetOld = SigSetOld;
    82 
    83         LIBCLOG_RETURN_MSG(0, "ret 0 old={%08lx%08lx} new={%08lx%08lx}\n",
    84                            SigSetOld.__bitmap[1], SigSetOld.__bitmap[0],
    85                            SigSetNew.__bitmap[1], SigSetNew.__bitmap[0]);
     82        LIBCLOG_RETURN_MSG(0, "ret 0 old={%08lx%08lx}\n", SigSetOld.__bitmap[1], SigSetOld.__bitmap[0]);
    8683    }
    8784    errno = -rc;
  • trunk/src/emx/src/lib/process/sigrelse.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3232#include <signal.h>
    3333#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    35 #include <InnoTekLIBC/thread.h>
     34#include <InnoTekLIBC/backend.h>
    3635#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3736#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigsetmask.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    35 #include <InnoTekLIBC/thread.h>
     33#include <InnoTekLIBC/backend.h>
    3634#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3735#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigsuspend.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3333#include <signal.h>
    3434#include <errno.h>
    35 #include <InnoTekLIBC/signals.h>
    3635#include <InnoTekLIBC/thread.h>
     36
    3737#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3838#include <InnoTekLIBC/logstrict.h>
     
    4949    LIBCLOG_ENTER("pSigSet=%p {%08lx%08lx}\n",
    5050                  (void *)pSigSet, pSigSet ? pSigSet->__bitmap[1] : 0, pSigSet ? pSigSet->__bitmap[0] : 0);
    51     __LIBC_PTHREAD  pThrd = __libc_threadCurrent();
    52     sigset_t        SigSet;
    5351
    5452    /*
    55      * Make copy of the input (we can safely crash here).
     53     * .
    5654     */
    57     SigSet = *pSigSet;
    58 
    59     /*
    60      * Gain exclusive access to the signal stuff.
    61      */
    62     if (__libc_back_signalSemRequest())
     55    int rc = __libc_Back_signalSuspend(pSigSet);
     56    if (rc)
     57    {
     58        errno = -rc;
    6359        LIBCLOG_RETURN_INT(-1);
    64 
    65     /*
    66      * Change the signal mask.
    67      */
    68     pThrd->SigSetBlockedOld     = pThrd->SigSetBlocked;
    69     pThrd->fSigSetBlockedOld    = 1;
    70     pThrd->SigSetBlocked        = SigSet;
    71 
    72     /*
    73      * Go to sleep but check for pending signals first.
    74      *
    75      * We have to do this call from within the sem+mustcomplete section.
    76      * The backend function will leave the section.
    77      */
    78     __libc_back_signalSuspend();
    79 
    80 
    81     /*
    82      * Return interrupt failure.
    83      */
    84     errno = EINTR;
    85     LIBCLOG_RETURN_INT(-1);
     60    }
     61    LIBCLOG_RETURN_INT(0);
    8662}
  • trunk/src/emx/src/lib/process/sigtimedwait.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <assert.h>
    34 #include <InnoTekLIBC/signals.h>
     33#include <errno.h>
    3534#include <InnoTekLIBC/thread.h>
     35
    3636#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3737#include <InnoTekLIBC/logstrict.h>
     
    4040
    4141/**
    42  * Wait for a signal to become pending.
     42 * Wait for one or more signals and remove and return the first of them
     43 * to occur.
    4344 *
    44  * @returns 0 on success.
     45 * Will return immediately if one of the signals is already pending. If more than
     46 * one signal is pending the signal with highest priority will be returned.
     47 *
     48 * @returns Signal number on success.
    4549 * @returns -1 on failure, errno set.
    4650 * @param   pSigSet     Signals to wait for.
    4751 * @param   pSigInfo    Where to store the signal info for the signal
    4852 *                      that we accepted.
     53
    4954 */
    5055int _STD(sigtimedwait)(const sigset_t *pSigSet, siginfo_t *pSigInfo, const struct timespec *pTimeout)
     
    5459                  (void *)pSigInfo,
    5560                  (void *)pTimeout, pTimeout ? pTimeout->tv_sec : ~0, pTimeout ? pTimeout->tv_nsec : ~0);
    56     __LIBC_PTHREAD  pThrd = __libc_threadCurrent();
    57     sigset_t        SigSet;
    58     siginfo_t       SigInfo = {0};
    59     struct timespec Timeout;
    60     int             rc;
    6161
    6262    /*
    63      * Make copy of the input (we can safely crash here).
     63     * .
    6464     */
    65     SigSet = *pSigSet;
    66     if (pTimeout)
    67         Timeout = *pTimeout;
     65    siginfo_t SigInfo;
     66    int rc = __libc_Back_signalWait(pSigSet, &SigInfo, pTimeout);
     67    if (!rc)
     68    {
     69        if (pSigInfo)
     70            *pSigInfo = SigInfo;
     71        LIBCLOG_RETURN_MSG(rc, "ret %d (*pSigInfo={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",
     72                           rc, SigInfo.si_signo, SigInfo.si_errno, SigInfo.si_code, SigInfo.si_timestamp,
     73                           SigInfo.si_flags, SigInfo.si_pid, SigInfo.si_tid, SigInfo.si_uid, SigInfo.si_status,
     74                           SigInfo.si_addr, SigInfo.si_value.sigval_int, SigInfo.si_band);
     75    }
    6876
    69     /*
    70      * Gain exclusive access to the signal stuff.
    71      */
    72     if (__libc_back_signalSemRequest())
    73         LIBCLOG_RETURN_INT(-1);
    74 
    75     /*
    76      * Mark thread as blocked in begin in sigtimedwait().
    77      */
    78     if (pThrd->enmStatus != enmLIBCThreadStatus_unknown)
    79     {
    80         LIBC_ASSERTM_FAILED("Must push thread state!\n");
    81         __libc_back_signalSemRelease();
    82         assert(0);
    83         LIBCLOG_RETURN_INT(-1);
    84     }
    85     pThrd->enmStatus            = enmLIBCThreadStatus_sigwait;
    86     pThrd->u.SigWait.SigSetWait = SigSet;
    87     pThrd->u.SigWait.pSigInfo   = &SigInfo;
    88 
    89     /*
    90      * Go to sleep.
    91      *
    92      * We have to do this call from within the sem+mustcomplete section.
    93      * The backend function will leave the section.
    94      */
    95     rc = __libc_back_signalWait(pTimeout ? &Timeout : NULL);
    96 
    97     /*
    98      * Store result.
    99      */
    100     if (pSigInfo)
    101         *pSigInfo = SigInfo;
    102 
    103     LIBCLOG_RETURN_MSG(rc, "ret %d (*pSigInfo={si_signo=%d, si_errno=%d, si_code=%#x, si_pid=%d, si_uid=%d, si_status=%d, si_addr=%p, si_value=%#08x, si_band=%ld})\n",
    104                        rc, SigInfo.si_signo, SigInfo.si_errno, SigInfo.si_code, SigInfo.si_pid, SigInfo.si_uid,
    105                        SigInfo.si_status, SigInfo.si_addr, SigInfo.si_value.sigval_int, SigInfo.si_band);
     77    errno = -rc;
     78    LIBCLOG_RETURN_INT(-1);
    10679}
    10780
  • trunk/src/emx/src/lib/process/sigvec.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3232#include <signal.h>
    3333#include <errno.h>
    34 #include <InnoTekLIBC/signals.h>
    3534#include <InnoTekLIBC/thread.h>
     35
    3636#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3737#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigwait.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <InnoTekLIBC/signals.h>
    3433#include <InnoTekLIBC/thread.h>
     34
    3535#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3636#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/sigwaitinfo.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3131#include "libc-alias.h"
    3232#include <signal.h>
    33 #include <InnoTekLIBC/signals.h>
    3433#include <InnoTekLIBC/thread.h>
     34
    3535#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3636#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/process/thread_internals.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1617 r1618  
    4141#include <InnoTekLIBC/thread.h>
    4242#include <InnoTekLIBC/backend.h>
    43 #include <InnoTekLIBC/signals.h>
    4443#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_THREAD
    4544#include <InnoTekLIBC/logstrict.h>
     
    8887    pThrd->iRand = 1;
    8988    pThrd->cRefs = 1;
    90     /* ASSUMES sigemptyset() is equivalent with memsetting a sigset_t. */
    91     if (pParentThrd)
    92     {
    93         /*
    94          * Gain exclusive access to the signal stuff.
    95          */
    96         int rc = __libc_back_signalSemRequest();
    97 
    98         /*
    99          * Copy signal stuff.
    100          */
    101         pThrd->SigSetBlocked    = pParentThrd->SigSetBlocked;
    102         if (pParentThrd->fSigSetBlockedOld)
    103         {
    104             pThrd->SigSetBlockedOld     = pParentThrd->SigSetBlockedOld;
    105             pThrd->fSigSetBlockedOld    = pParentThrd->fSigSetBlockedOld;
    106         }
    107 
    108         /*
    109          * Release semaphore.
    110          */
    111         if (!rc)
    112             __libc_back_signalSemRelease();
    113     }
    114     else
    115     {
    116         /** @todo try find info from parent process. */
    117     }
    118 
    11989    __libc_Back_threadInit(pThrd, pParentThrd);
    12090}
  • trunk/src/emx/src/lib/sys/__init.c

    • Property cvs2svn:cvs-rev changed from 1.17 to 1.18
    r1617 r1618  
    2929#include <InnoTekLIBC/sharedpm.h>
    3030#include <InnoTekLIBC/backend.h>
    31 #include <InnoTekLIBC/signals.h>
    3231#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_INITTERM
    3332#include <InnoTekLIBC/logstrict.h>
     33
    3434
    3535
  • trunk/src/emx/src/lib/sys/__initdll.c

    • Property cvs2svn:cvs-rev changed from 1.17 to 1.18
    r1617 r1618  
    3535#include "syscalls.h"
    3636#include "fs.h"
     37
    3738#include <InnoTekLIBC/thread.h>
    3839#include <InnoTekLIBC/libc.h>
    39 #include <InnoTekLIBC/signals.h>
     40#include <InnoTekLIBC/.h>
    4041#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_INITTERM
    4142#include <InnoTekLIBC/logstrict.h>
  • trunk/src/emx/src/lib/sys/b_signalMask.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    4848 *
    4949 * @returns 0 on success.
    50  * @returns -1 and errno set to EINVAL on failure.
     50 * @returns on failure.
    5151 * @param   pThrd       Thread to apply this to.
    5252 * @param   iHow        Describes the action taken if pSigSetNew not NULL. Recognized
  • trunk/src/emx/src/lib/sys/b_signalStack.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3030*******************************************************************************/
    3131#include "libc-alias.h"
    32 #define INCL_BASE
    33 #define INCL_FSMACROS
    34 #define INCL_DOSSIGNALS
    35 #include <os2emx.h>
    36 
    3732#include <signal.h>
    3833#include <errno.h>
     
    4136#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_SIGNAL
    4237#include <InnoTekLIBC/logstrict.h>
    43 #include "syscalls.h"
     38#include "sls.h"
    4439
    4540/**
  • trunk/src/emx/src/lib/sys/b_signalSuspend.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    2929*   Header Files                                                               *
    3030*******************************************************************************/
    31 #define INCL_BASE
    32 #define INCL_FSMACROS
    33 #include <os2emx.h>
    34 
     31#include "libc-alias.h"
    3532#include <signal.h>
    3633#include <errno.h>
    37 #include <InnoTekLIBC/signals.h>
    38 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
     34#include <InnoTekLIBC/thread.h>
     35#include <InnoTekLIBC/backend.h>
     36#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_SIGNAL
    3937#include <InnoTekLIBC/logstrict.h>
    40 
    41    
    42 /*******************************************************************************
    43 *   Structures and Typedefs                                                    *
    44 *******************************************************************************/
    45 /** Registration record for signalSuspendXcptHandler(). */
    46 typedef struct XCPTREGREC
    47 {
    48     EXCEPTIONREGISTRATIONRECORD     Core;
    49     /** This event semaphore is signaled when a signal has been
    50      * processed by the current thread. */
    51     HEV                             hev;
    52 } XCPTREGREC, *PXCPTREGREC;
    53 
    54 
    55 /*******************************************************************************
    56 *   Internal Functions                                                         *
    57 *******************************************************************************/
    58 static ULONG _System signalSuspendXcptHandler(PEXCEPTIONREPORTRECORD pXcptRec,  PEXCEPTIONREGISTRATIONRECORD pRegRec, PCONTEXTRECORD pCtx, PVOID pvSomething);
    59 
    60 
    61 /**
    62  * Exception handler use while waitin for signals to be
    63  * delivered to this thread or the process being terminated.
    64  */
    65 static ULONG _System signalSuspendXcptHandler(PEXCEPTIONREPORTRECORD pXcptRec,  PEXCEPTIONREGISTRATIONRECORD pRegRec, PCONTEXTRECORD pCtx, PVOID pvSomething)
    66 {
    67     /* a thread counter? */
    68     /** @todo implement me! */
    69     return XCPT_CONTINUE_SEARCH;
    70 }
     38#include "signals.h"
    7139
    7240
     
    7543 * The signal semaphore is owned.
    7644 */
    77 int         __libc_back_signalSuspend(void)
     45int         __libc_)
    7846{
    79     LIBCLOG_ENTER("\n");
    80     int         rc;
    81     XCPTREGREC  XcptReg;
    82     FS_VAR();
     47    LIBCLOG_ENTER("pSigSet=%p {%08lx%08lx}\n",
     48                  (void *)pSigSet, pSigSet ? pSigSet->__bitmap[1] : 0, pSigSet ? pSigSet->__bitmap[0] : 0);
     49    __LIBC_PTHREAD              pThrd = __libc_threadCurrent();
     50    sigset_t                    SigSet = *pSigSet;
     51    __LIBC_THREAD_SIGSUSPEND    SigSuspend = {0};
    8352
    8453    /*
    85      * Register
     54     *
    8655     */
    87     FS_SAVE_LOAD();
    88     XcptReg.Core.ExceptionHandler = signalSuspendXcptHandler;
    89     XcptReg.Core.prev_structure = (void *)~0;
    90     rc = DosCreateEventSem(NULL, &XcptReg.hev, 0, FALSE);
    91     if (!rc)
    92     {
    93         rc = DosSetExceptionHandler(&XcptReg.Core);
    94         if (!rc)
    95         {
    96             PPIB    pPib;
    97             PTIB    pTib;
    98            
    99             /*
    100              * Time to release the semaphore.
    101              */
    102             __libc_back_signalSemRelease();
    103             if (pTib->tib_ptib2->tib2_usMCCount)
    104             {
    105                 LIBC_ASSERTM_FAILED("Deadlock avoided. tried to wait for signal with must complete count %d\n", pTib->tib_ptib2->tib2_usMCCount);
    106                 LIBCLOG_RETURN_INT(-EDEADLK);
    107             }
     56    int rc =__libc_back_signalSemRequest();
     57    if (rc)
     58        LIBCLOG_RETURN_INT(rc);
    10859
    109             /*
    110              * Wait loop.
    111              */
    112             DosGetInfoBlocks(&pTib, &pPib);
    113             for (;;)
    114             {
    115                 rc = DosWaitEventSem(XcptReg.hev, 30*1000);
    116                 if (!rc)
    117                     break;
     60    /*
     61     .
     62     */
     63    ;
     64   
     65   
     66    ;
     67   
     68    ;
    11869
    119                 /* Avoid deadlocks during termination. */
    120                 if (pPib->pib_flstatus & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/* ExitList */))
    121                 {
    122                     LIBCLOG_MSG("resuming execution, anyhow. the process is terminating. (status=%#lx\n", pPib->pib_flstatus);
    123                     break;
    124                 }
    125             }
    126 
    127             DosUnsetExceptionHandler(&XcptReg.Core);
    128         }
    129         DosCloseEventSem(XcptReg.hev);
    130     }
    131 
    132     FS_RESTORE();
    133     LIBCLOG_RETURN_INT(0);
     70    /*
     71     * Perform signal wait and return.
     72     */
     73    rc = __libc_back_signalWait(pThrd, &SigSuspend.fDone, NULL);
     74    if (rc != EAGAIN)
     75        __libc_back_signalSemRelease();
     76    LIBCLOG_RETURN_INT(rc);
    13477}
    13578
  • trunk/src/emx/src/lib/sys/b_signalWait.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3737#include <errno.h>
    3838#include <386/builtin.h>
    39 #include <InnoTekLIBC/signals.h>
     39#include
    4040#include <InnoTekLIBC/thread.h>
     41
    4142#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    4243#include <InnoTekLIBC/logstrict.h>
    4344
    4445
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
    4566
    46 int         __libc_back_signalWait(const struct timespec *pTimeout)
    47 {
    48     LIBCLOG_ENTER("pTimeout=%p {tv_sec=%d tv_nsec=%ld}\n",
    49                   (void *)pTimeout,
    50                   pTimeout->tv_sec,
    51                   pTimeout->tv_nsec);
    52     /** @todo Implement me */
    53 #if 0
    54     sigset_t        SigSetPending;
     67    __LIBC_PTHREAD  pThrd = __libc_threadCurrent();
     68    sigset_t                        SigSet;
     69    __LIBC_THREAD_SIGWAIT           SigWait = {0};
     70    struct timespec                 Timeout;
     71    int                             rc;
    5572
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
    5697    if (    !__SIGSET_ISEMPTY(&pThrd->SigSetPending)
    5798        ||  !__SIGSET_ISEMPTY(&__libc_gSignalPending))
    5899    {
     100
    59101        __SIGSET_OR(&SigSetPending, &pThrd->SigSetPending, &__libc_gSignalPending);
    60         __SIGSET_AND(&SigSetPending, &SigSetPending, &SigSet);
     102        __SIGSET_AND(&SigSetPending, &SigSetPending, &SigSet);
    61103        if (!__SIGSET_ISEMPTY(&SigSetPending))
    62             rc = __libc_back_signalAccept();
     104        {
     105            rc = __libc_back_signalAccept(pThrd, 0, &SigSetPending, (siginfo_t *)&SigWait.SigInfo);
     106            if (rc > 0)
     107            {
     108                if (pSigInfo)
     109                    *pSigInfo = SigWait.SigInfo;
     110                __libc_back_signalSemRelease();
     111                LIBCLOG_RETURN_INT(rc);
     112            }
     113            LIBC_ASSERT_FAILED();
     114        }
    63115    }
    64 #endif
    65     LIBCLOG_RETURN_INT(-1);
     116
     117    /*
     118     * Mark thread as blocked in sigtimedwait().
     119     */
     120    if (pThrd->enmStatus != enmLIBCThreadStatus_unknown)
     121    {
     122        LIBC_ASSERTM_FAILED("Must push thread state!\n");
     123        __libc_back_signalSemRelease();
     124        LIBCLOG_RETURN_INT(-EDEADLK);
     125    }
     126    SigWait.fDone           = 0;
     127    SigWait.SigSetWait      = SigSet;
     128    SigWait.SigInfo.si_signo= 0;
     129    pThrd->u.pSigWait   = &SigWait;
     130    pThrd->enmStatus    = enmLIBCThreadStatus_sigwait;
     131
     132    /*
     133     * Wait till state changes back and then return according to the wait result.
     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. :-)
     139     */
     140    rc = __libc_back_signalWait(pThrd, &SigWait.fDone, pTimeout ? &Timeout : NULL);
     141    if (rc != -EAGAIN)
     142        __libc_back_signalSemRelease();
     143    if (rc == -EINTR)
     144    {
     145        if (SigWait.fDone && SigWait.SigInfo.si_signo > 0)
     146        {
     147            rc = SigWait.SigInfo.si_signo;
     148            if (pSigInfo)
     149                *pSigInfo = SigWait.SigInfo;
     150        }
     151    }
     152
     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                       rc, SigWait.SigInfo.si_signo, SigWait.SigInfo.si_errno, SigWait.SigInfo.si_code, SigWait.SigInfo.si_timestamp,
     155                       SigWait.SigInfo.si_flags, SigWait.SigInfo.si_pid, SigWait.SigInfo.si_tid, SigWait.SigInfo.si_uid, SigWait.SigInfo.si_status,
     156                       SigWait.SigInfo.si_addr, SigWait.SigInfo.si_value.sigval_int, SigWait.SigInfo.si_band);
    66157}
    67158
  • trunk/src/emx/src/lib/sys/b_threadInit.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1617 r1618  
    3333#include <emx/syscalls.h>
    3434#include "syscalls.h"
     35
    3536#include <InnoTekLIBC/thread.h>
    3637#include <InnoTekLIBC/backend.h>
     
    4142    pThrd->b.sys.fd.hdir = HDIR_CREATE;
    4243    pThrd->b.sys.fd.cFiles = 0;
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
    4366}
    4467
  • trunk/src/emx/src/lib/sys/exceptions.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1617 r1618  
    3737#include <errno.h>
    3838#include <386/builtin.h>
    39 #include <InnoTekLIBC/signals.h>
    4039#include <InnoTekLIBC/thread.h>
    4140#include <InnoTekLIBC/backend.h>
    4241#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    4342#include <InnoTekLIBC/logstrict.h>
     43
    4444
    4545
  • trunk/src/emx/src/lib/sys/sharedpm.c

    • Property cvs2svn:cvs-rev changed from 1.14 to 1.15
    r1617 r1618  
    892892{
    893893    __atomic_xchg(&gpSPMSelf->fExeInited, 1);
    894     return 0;
    895894}
    896895
  • trunk/src/emx/src/lib/sys/signals.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1617 r1618  
    10271027         */
    10281028        if (   pThrdSig->enmStatus == enmLIBCThreadStatus_sigwait
    1029             && __SIGSET_ISSET(&pThrdSig->u.SigWait.SigSetWait, iSignalNo))
     1029            && __SIGSET_ISSET(&pThrdSig->u.SigSetWait, iSignalNo))
    10301030        {
    10311031            /*
    10321032             * Wake up a sigwait call.
    10331033             */
    1034             /** @todo install extra exception handler while accessing this. */
    10351034            if (pSigInfo)
    1036                 *pThrdSig->u.SigWait.pSigInfo = *pSigInfo;
     1035                SigInfo = *pSigInfo;
    10371036            else
    1038             {
    1039                 bzero(pThrdSig->u.SigWait.pSigInfo, sizeof(*pThrdSig->u.SigWait.pSigInfo));
    1040                 pThrdSig->u.SigWait.pSigInfo->si_signo = iSignalNo;
    1041             }
     1037                bzero((void *)&pThrdSig->u.pSigWait->SigInfo, sizeof(pThrdSig->u.pSigWait->SigInfo));
     1038            pThrdSig->u.pSigWait->SigInfo.si_signo = iSignalNo;
     1039            pThrdSig->u.pSigWait->fDone = 1;
    10421040            pThrdSig->enmStatus = enmLIBCThreadStatus_unknown;
     1041
     1042
     1043
     1044
     1045
     1046
     1047
     1048
     1049
     1050
     1051
     1052
     1053
     1054
     1055
    10431056            if (pThrdSig != pThrd)
    10441057                __libc_back_signalPokeThread(pThrdSig);
    1045             LIBCLOG_MSG("wokeup sigwait in thread %d on signal %d.\n", pThrdSig->tid, iSignalNo);
     1058            LIBCLOG_MSG("wokeup sigwait in thread % on signal %d.\n", pThrdSig->tid, iSignalNo);
    10461059        }
    10471060        else
     
    11161129                if (pThrdSig != pThrd)
    11171130                    __libc_back_signalPokeThread(pThrdSig);
    1118                 LIBCLOG_MSG("setting %d pending on thread %d's and poking it.\n", pThrdSig->tid, iSignalNo);
     1131                LIBCLOG_MSG("setting %d pending on thread %'s and poking it.\n", pThrdSig->tid, iSignalNo);
    11191132            }
    11201133        }
     
    13511364
    13521365    /*
    1353      * If we've got a queue node, queue it.
    1354      */
    1355     if (pSig)
    1356     {
    1357         pSig->pNext = NULL;
    1358         pSig->pPrev = pThrdSig->SigQueue.pTail;
    1359         if (pThrdSig->SigQueue.pTail)
    1360             pThrdSig->SigQueue.pTail->pNext = pSig;
     1366     * Check if this was a sig*wait* case.
     1367     */
     1368    if (   pThrdSig->enmStatus == enmLIBCThreadStatus_sigwait
     1369        && __SIGSET_ISSET(&pThrdSig->u.pSigWait->SigSetWait, iSignalNo))
     1370    {
     1371        /*
     1372         * Store result with the thread.
     1373         */
     1374        if (pSig)
     1375            pThrdSig->u.pSigWait->SigInfo = pSig->SigInfo;
    13611376        else
    1362             pThrdSig->SigQueue.pHead = pSig;
    1363         pThrdSig->SigQueue.pTail = pSig;
    1364     }
    1365 
    1366     /*
    1367      * In any case, we set the signal pending and poke the thread.
    1368      */
    1369     __SIGSET_SET(&pThrd->SigSetPending, iSignalNo);
    1370     if (pThrdSig != pThrd)
    1371         __libc_back_signalPokeThread(pThrdSig);
    1372     LIBCLOG_MSG("setting %d pending on thread %d's and poking it.\n", pThrdSig->tid, iSignalNo);
     1377            bzero((void *)&pThrdSig->u.pSigWait->SigInfo, sizeof(pThrdSig->u.pSigWait->SigInfo));
     1378        pThrdSig->u.pSigWait->SigInfo.si_signo = iSignalNo;
     1379        pThrdSig->u.pSigWait->fDone = 1;
     1380        pThrdSig->enmStatus = enmLIBCThreadStatus_unknown;
     1381
     1382        /*
     1383         * Free the signal node.
     1384         */
     1385        pSig->pNext = gpSigQueuedFree;
     1386        gpSigQueuedFree = pSig->pNext;
     1387        gcSigQueuedFree++;
     1388
     1389        /*
     1390         * Check if there is an unqueued pending signal which we should clear.
     1391         */
     1392        pSig = pThrdSig->SigQueue.pHead;
     1393        while (pSig && pSig->SigInfo.si_signo != iSignalNo)
     1394            pSig = pSig->pNext;
     1395        if (!pSig)
     1396            __SIGSET_CLEAR(&pThrdSig->SigSetPending, iSignalNo);
     1397        else
     1398            __SIGSET_SET(&pThrdSig->SigSetPending, iSignalNo);
     1399
     1400        /*
     1401         * Poke the thread.
     1402         */
     1403        if (pThrdSig != pThrd)
     1404            __libc_back_signalPokeThread(pThrdSig);
     1405        LIBCLOG_MSG("wokeup sigwait in thread %#x on signal %d.\n", pThrdSig->tid, iSignalNo);
     1406    }
     1407    else
     1408    {
     1409        /*
     1410         * If we've got a queue node, queue it.
     1411         */
     1412        if (pSig)
     1413        {
     1414            pSig->pNext = NULL;
     1415            pSig->pPrev = pThrdSig->SigQueue.pTail;
     1416            if (pThrdSig->SigQueue.pTail)
     1417                pThrdSig->SigQueue.pTail->pNext = pSig;
     1418            else
     1419                pThrdSig->SigQueue.pHead = pSig;
     1420            pThrdSig->SigQueue.pTail = pSig;
     1421        }
     1422
     1423        /*
     1424         * And in any case set it pending.
     1425         */
     1426        __SIGSET_SET(&pThrd->SigSetPending, iSignalNo);
     1427
     1428        /*
     1429         * Poke the thread.
     1430         */
     1431        if (pThrdSig != pThrd)
     1432            __libc_back_signalPokeThread(pThrdSig);
     1433        LIBCLOG_MSG("setting %d pending on thread %#x's and poking it.\n", pThrdSig->tid, iSignalNo);
     1434    }
     1435
    13731436    LIBCLOG_RETURN_VOID();
    13741437}
     
    13861449{
    13871450    LIBC_ASSERTM(__libc_back_signalSemIsOwner(), "Thread does not own the signal semaphore!!!\n");
     1451
     1452
     1453
     1454
     1455
     1456
     1457
     1458
     1459
     1460
    13881461
    13891462    /*
     
    14231496     */
    14241497    if (   pCur->enmStatus == enmLIBCThreadStatus_sigwait
    1425         && __SIGSET_ISSET(&pCur->u.SigWait.SigSetWait, pParam->iSignalNo))
     1498        && __SIGSET_ISSET(&pCur->u.SigSetWait, pParam->iSignalNo))
    14261499    {
    14271500        if (pCur == pParam->pThrd)
     
    14431516        ||  (   pBest
    14441517             && pBest->enmStatus == enmLIBCThreadStatus_sigwait
    1445              && __SIGSET_ISSET(&pCur->u.SigWait.SigSetWait, pParam->iSignalNo)))
     1518             && __SIGSET_ISSET(&pSigSetWait, pParam->iSignalNo)))
    14461519        return 0;
    14471520    /* ok, it's not blocking it so it's ok to use it. */
     
    15521625
    15531626        /*
    1554          * Deliver signals /execute signal default actions in this order:
    1555          *   0. Passed in signal (ignores blocking).
    1556          *   1. SIGKILL
    1557          *   2. Realtime signals. (queued)
    1558          *   3. SIGTERM
    1559          *   4. SIGABRT
    1560          *   5. SIGCHLD
    1561          *   6. SIGCONT
    1562          *   7. Ascending from pending mask.
    1563          *
    1564          * Note that 0 and 1 may be violating the POSIX specs.
    1565          */
    1566         if (!iSignalNo || !__SIGSET_ISSET(&pThrd->SigSetPending, iSignalNo))
    1567         {
    1568             iSignalNo = SIGKILL;
    1569             if (!__SIGSET_ISSET(&SigDeliver, SIGKILL))
    1570             {
    1571                 iSignalNo = SIGRTMIN;
    1572                 while (iSignalNo <= SIGRTMAX && !__SIGSET_ISSET(&SigDeliver, iSignalNo))
    1573                     iSignalNo++;
    1574                 if (iSignalNo > SIGRTMAX)
    1575                 {
    1576                     iSignalNo = SIGTERM;
    1577                     if (!__SIGSET_ISSET(&SigDeliver, SIGTERM))
    1578                     {
    1579                         iSignalNo = SIGABRT;
    1580                         if (!__SIGSET_ISSET(&SigDeliver, SIGABRT))
    1581                         {
    1582                             iSignalNo = SIGCHLD;
    1583                             if (!__SIGSET_ISSET(&SigDeliver, SIGCHLD))
    1584                             {
    1585                                 iSignalNo = SIGCONT;
    1586                                 if (!__SIGSET_ISSET(&SigDeliver, SIGCONT))
    1587                                 {
    1588                                     iSignalNo = 1;
    1589                                     while (iSignalNo < SIGRTMIN && !__SIGSET_ISSET(&SigDeliver, iSignalNo))
    1590                                         iSignalNo++;
    1591                                     if (iSignalNo >= SIGRTMIN)
    1592                                     {
    1593                                         LIBC_ASSERTM_FAILED("Internal error!!!\n");
    1594                                         LIBCLOG_RETURN_INT(__LIBC_BSRR_CONTINUE);
    1595                                     }
    1596                                 }
    1597                             }
    1598                         }
    1599                     }
    1600                 }
    1601             }
    1602         }
    1603 
    1604         /*
    1605          * Check if there is a queue element for the signal.
    1606          */
    1607         siginfo_t   SigInfo = {0};
    1608         PSIGQUEUED pSig = pThrd->SigQueue.pHead;
    1609         while (pSig)
    1610         {
    1611             if (pSig->SigInfo.si_signo == iSignalNo)
    1612             {
    1613                 /* unlink */
    1614                 if (pSig->pPrev)
    1615                     pSig->pPrev->pNext    = pSig->pNext;
    1616                 else
    1617                     pThrd->SigQueue.pHead = pSig->pNext;
    1618                 if (pSig->pNext)
    1619                     pSig->pNext->pPrev    = pSig->pPrev;
    1620                 else
    1621                     pThrd->SigQueue.pTail = pSig->pPrev;
    1622 
    1623                 /*
    1624                  * Check if more signals of this type so we can update the
    1625                  * pending mask correctly.
    1626                  */
    1627                 PSIGQUEUED pSigMore = pSig->pNext;
    1628                 while (pSigMore && pSigMore->SigInfo.si_signo != iSignalNo)
    1629                     pSigMore = pSigMore->pNext;
    1630                 if (!pSigMore)
    1631                     __SIGSET_CLEAR(&pThrd->SigSetPending, iSignalNo);
    1632 
    1633                 /*
    1634                  * Copy the signal to the SigInfo structure on the stack
    1635                  * and then release the signal queue structure.
    1636                  */
    1637                 SigInfo = pSig->SigInfo;
    1638                 break;
    1639             }
    1640             /* next */
    1641             pSig = pSig->pNext;
    1642         }
    1643 
    1644         /*
    1645          * If no queued signal data, then we can simply clear it in the pending mask.
    1646          */
    1647         if (!pSig)
    1648         {
    1649             SigInfo.si_signo = iSignalNo;
    1650             __SIGSET_CLEAR(&pThrd->SigSetPending, iSignalNo);
    1651         }
    1652 
    1653 
    1654         /*
    1655          * What to do for this signal?
    1656          */
     1627         * Accept the signal.
     1628         */
     1629        siginfo_t SigInfo;
     1630        if (iSignalNo && __SIGSET_ISSET(&pThrd->SigSetPending, iSignalNo))
     1631            iSignalNo = __libc_back_signalAccept(pThrd, iSignalNo, &SigDeliver, &SigInfo);
     1632        LIBC_ASSERTM(__SIGSET_SIG_VALID(iSignalNo), "iSignalNo=%d\n", iSignalNo);
    16571633        struct sigaction SigAction = gaSignalActions[iSignalNo];
     1634
     1635
     1636
     1637
     1638
     1639
     1640
     1641
     1642
     1643
     1644
     1645
     1646
     1647
     1648
     1649
     1650
     1651
     1652
     1653
     1654
     1655
     1656
     1657
     1658
     1659
     1660
     1661
     1662
     1663
     1664
     1665
     1666
    16581667        if (    SigAction.__sigaction_u.__sa_handler == SIG_IGN
    16591668            ||  (   SigAction.__sigaction_u.__sa_handler == SIG_DFL
     
    16661675        }
    16671676
     1677
     1678
     1679
    16681680        if (SigAction.__sigaction_u.__sa_handler == SIG_DFL)
    16691681        {
     
    17301742            if (gafSignalProperties[iSignalNo] & SPP_NOBLOCK)
    17311743                __SIGSET_CLEAR(&SigAction.sa_mask, iSignalNo);
    1732             sigset_t SigSetOld = pThrd->SigSetBlocked;
     1744            sigset_t SigSetOld = d;
    17331745            __SIGSET_OR(&pThrd->SigSetBlocked, &pThrd->SigSetBlocked, &SigAction.sa_mask);
    17341746
     
    19922004static int signalJobStop(int iSignalNo)
    19932005{
    1994     LIBC_ASSERTM(__libc_threadCurrent()->tid == 1, "Invalid thread %d\n", __libc_threadCurrent()->tid);
     2006    LIBC_ASSERTM(__libc_threadCurrent()->tid == 1, "Invalid thread %\n", __libc_threadCurrent()->tid);
    19952007
    19962008    /*
     
    20192031static int signalJobResume(void)
    20202032{
    2021     LIBC_ASSERTM(__libc_threadCurrent()->tid == 1, "Invalid thread %d\n", __libc_threadCurrent()->tid);
     2033    LIBC_ASSERTM(__libc_threadCurrent()->tid == 1, "Invalid thread %\n", __libc_threadCurrent()->tid);
    20222034
    20232035    /*
     
    23582370 *
    23592371 * @returns 0 on success.
    2360  * @returns -Negative errno on failure.
     2372 * @returns on failure.
    23612373 * @param   iSignalNo   Signal number.
    23622374 * @param   pSigAct     Pointer to new signal action.
     
    25572569
    25582570/**
     2571
     2572
     2573
     2574
     2575
     2576
     2577
     2578
     2579
     2580
     2581
     2582
     2583
     2584
     2585
     2586
     2587
     2588
     2589
     2590
     2591
     2592
     2593
     2594
     2595
     2596
     2597
     2598
     2599
     2600
     2601
     2602
     2603
     2604
     2605
     2606
     2607
     2608
     2609
     2610
     2611
     2612
     2613
     2614
     2615
     2616
     2617
     2618
     2619
     2620
     2621
     2622
     2623
     2624
     2625
     2626
     2627
     2628
     2629
     2630
     2631
     2632
     2633
     2634
     2635
     2636
     2637
     2638
     2639
     2640
     2641
     2642
     2643
     2644
     2645
     2646
     2647
     2648
     2649
     2650
     2651
     2652
     2653
     2654
     2655
     2656
     2657
     2658
     2659
     2660
     2661
     2662
     2663
     2664
     2665
     2666
     2667
     2668
     2669
     2670
     2671
     2672
     2673
     2674
     2675
     2676
     2677
     2678
     2679
     2680
     2681
     2682
     2683
     2684
     2685
     2686
     2687
     2688
     2689
     2690
     2691
     2692
     2693
     2694
     2695
     2696
     2697
     2698
     2699
     2700
     2701
     2702
     2703
     2704
     2705
     2706
     2707
     2708
     2709
     2710
     2711
     2712
     2713
     2714
     2715
     2716
     2717
     2718
     2719
     2720
     2721
     2722
     2723
     2724
     2725
     2726
     2727
     2728
     2729
     2730
     2731
     2732
     2733
     2734
     2735
     2736
     2737
     2738
     2739
     2740
     2741
     2742
     2743
     2744
     2745
     2746
     2747
     2748
     2749
     2750
     2751
     2752
     2753
     2754
     2755
     2756
     2757
     2758
     2759
     2760
     2761
     2762
     2763
     2764
     2765
     2766
     2767
     2768
     2769
     2770
     2771
     2772
     2773
     2774
     2775
     2776
     2777
     2778
     2779
     2780
     2781
     2782
     2783
     2784
     2785
     2786
     2787
     2788
     2789
     2790
     2791
     2792
     2793
     2794
     2795
     2796
     2797
     2798
    25592799 * Gets the current timestamp.
    25602800 *
  • trunk/src/emx/src/lib/sys/signals.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1617 r1618  
    3030#include <sys/cdefs.h>
    3131#include <signal.h>
     32
    3233#include <InnoTekLIBC/backend.h>
    33 
    34 
    35 /** Signal set of the signals which will interrupt system call execution.
    36  * By default all signals will interrupt syscall execution, since OS/2 can't really
    37  * restart system calls easily.
    38  * Update is protected by the signal semaphore, however read access isn't.
    39  */
    40 extern sigset_t     __libc_gSignalRestartMask;
    4134
    4235/** Signal set for the signals which are pending on a process scope.
     
    5649void        __libc_back_signalPokeProcess(void);
    5750int         __libc_back_signalSuspend(void);
    58 int         __libc_back_signalWait(const struct timespec *pTimeout);
     51int         __libc_back_signalAccept(__LIBC_PTHREAD pThrd, int iSignalNo, sigset_t *pSigSet, siginfo_t *pSigInfo);
     52int         __libc_back_signalWait(__LIBC_PTHREAD pThrd, volatile int *pfDone, const struct timespec *pTimeout);
    5953int         __libc_back_signalSendPidOther(pid_t pid, int iSignalNo, siginfo_t *pSigInfo);
    6054int         __libc_back_signalAction(int iSignalNo, const struct sigaction *pSigAct, struct sigaction *pSigActOld);
Note: See TracChangeset for help on using the changeset viewer.