VirtualBox

Changeset 97646 in vbox for trunk


Ignore:
Timestamp:
Nov 22, 2022 1:02:48 AM (23 months ago)
Author:
vboxsync
Message:

IPRT: Added RTProcSignalName and a generic implementation of it.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r96864 r97646  
    18521852# define RTProcSetPriority                              RT_MANGLER(RTProcSetPriority)
    18531853# define RTProcShortName                                RT_MANGLER(RTProcShortName)
     1854# define RTProcSignalName                               RT_MANGLER(RTProcSignalName)
    18541855# define RTProcTerminate                                RT_MANGLER(RTProcTerminate)
    18551856# define RTProcWait                                     RT_MANGLER(RTProcWait)
  • trunk/include/iprt/process.h

    r96407 r97646  
    115115#endif
    116116
     117
     118/**
     119 * Translate a signal number to a short name on the form SIGXXXX.
     120 *
     121 * If the signal is not known, it will be formatted as a number into one of
     122 * several static buffers.  This means that there could be concurrency issues if
     123 * this suddenly happens on multiple threads, though that is unlikely.
     124 *
     125 * @returns Readonly string naming the signal.
     126 * @param   iSignal         The signal to name.
     127 */
     128RTDECL(const char *) RTProcSignalName(int iSignal);
    117129
    118130#ifdef IN_RING3
  • trunk/src/VBox/Runtime/Makefile.kmk

    r96925 r97646  
    780780        generic/RTPathGetCurrentDrive-generic.cpp \
    781781        generic/RTPathIsSame-generic.cpp \
     782        generic/RTProcSignalName-generic.cpp \
    782783        generic/RTTimerLRCreate-generic.cpp \
    783784        generic/rtStrFormatKernelAddress-generic.cpp \
  • trunk/src/VBox/Runtime/testcase/tstRTProcWait.cpp

    r96407 r97646  
    6868
    6969
     70static int DisplaySignalList(void)
     71{
     72    for (int iSig = 0; iSig < 128; iSig++)
     73        RTPrintf("%4d: %s\n", iSig, RTProcSignalName(iSig));
     74    return 0;
     75}
     76
     77
    7078int main(int argc, char **argv)
    7179{
     
    7381    if (argc == 2 && !strcmp(argv[1], "child"))
    7482        return 42;
     83    if (argc == 2 && !strcmp(argv[1], "signal-list"))
     84        return DisplaySignalList();
    7585
    7686    RTPrintf("tstRTWait: spawning a child in a separate thread and waits for it in the main thread...\n");
     
    113123        RTPrintf("tstRTWait: RTThreadCreate failed with rc=%Rrc!\n", rc);
    114124
     125    /*
     126     * Check signal names while we're here (excuse: relevant to reporting wait results).
     127     */
     128    for (int iSig = 0; iSig < 256; iSig++)
     129    {
     130        const char *pszSig = RTProcSignalName(iSig);
     131        if (!RTStrStartsWith(pszSig, "SIG") || pszSig[3] == '\0')
     132        {
     133            RTPrintf("tstWait: error: RTProcSignalName(%d) -> '%s'\n", iSig, pszSig);
     134            rc = -1;
     135        }
     136    }
     137
    115138    return RT_SUCCESS(rc) ? 0 : 1;
    116139}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette