{
    "content": [
        {
            "type": "text",
            "text": "# sigtrap (man)\n\n## NAME\n\nsigtrap - Perl pragma to enable simple signal handling\n\n## SYNOPSIS\n\nuse sigtrap;\nuse sigtrap qw(stack-trace old-interface-signals);  # equivalent\nuse sigtrap qw(BUS SEGV PIPE ABRT);\nuse sigtrap qw(die INT QUIT);\nuse sigtrap qw(die normal-signals);\nuse sigtrap qw(die untrapped normal-signals);\nuse sigtrap qw(die untrapped normal-signals\nstack-trace any error-signals);\nuse sigtrap 'handler' => \\&myhandler, 'normal-signals';\nuse sigtrap qw(handler myhandler normal-signals\nstack-trace error-signals);\n\n## DESCRIPTION\n\nThe sigtrap pragma is a simple interface to installing signal handlers.  You can have it\ninstall one of two handlers supplied by sigtrap itself (one which provides a Perl stack trace\nand one which simply \"die()\"s), or alternately you can supply your own handler for it to\ninstall.  It can be told only to install a handler for signals which are either untrapped or\nignored.  It has a couple of lists of signals to trap, plus you can supply your own list of\nsignals.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (5 subsections)\n- **EXAMPLES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "sigtrap",
        "section": "",
        "mode": "man",
        "summary": "sigtrap - Perl pragma to enable simple signal handling",
        "synopsis": "use sigtrap;\nuse sigtrap qw(stack-trace old-interface-signals);  # equivalent\nuse sigtrap qw(BUS SEGV PIPE ABRT);\nuse sigtrap qw(die INT QUIT);\nuse sigtrap qw(die normal-signals);\nuse sigtrap qw(die untrapped normal-signals);\nuse sigtrap qw(die untrapped normal-signals\nstack-trace any error-signals);\nuse sigtrap 'handler' => \\&myhandler, 'normal-signals';\nuse sigtrap qw(handler myhandler normal-signals\nstack-trace error-signals);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Provide a stack trace for the old-interface-signals:",
            "use sigtrap;",
            "Ditto:",
            "use sigtrap qw(stack-trace old-interface-signals);",
            "Provide a stack trace on the 4 listed signals only:",
            "use sigtrap qw(BUS SEGV PIPE ABRT);",
            "Die on INT or QUIT:",
            "use sigtrap qw(die INT QUIT);",
            "Die on HUP, INT, PIPE or TERM:",
            "use sigtrap qw(die normal-signals);",
            "Die on HUP, INT, PIPE or TERM, except don't change the behavior for signals which are already",
            "trapped or ignored:",
            "use sigtrap qw(die untrapped normal-signals);",
            "Die on receipt one of an of the normal-signals which is currently untrapped, provide a stack",
            "trace on receipt of any of the error-signals:",
            "use sigtrap qw(die untrapped normal-signals",
            "stack-trace any error-signals);",
            "Install myhandler() as the handler for the normal-signals:",
            "use sigtrap 'handler', \\&myhandler, 'normal-signals';",
            "Install myhandler() as the handler for the normal-signals, provide a Perl stack trace on",
            "receipt of one of the error-signals:",
            "use sigtrap qw(handler myhandler normal-signals",
            "stack-trace error-signals);",
            "perl v5.34.0                                 2025-07-25                               sigtrap(3perl)"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "stack-trace",
                        "lines": 14
                    },
                    {
                        "name": "normal-signals",
                        "lines": 3
                    },
                    {
                        "name": "error-signals",
                        "lines": 3
                    },
                    {
                        "name": "old-interface-signals",
                        "lines": 9
                    },
                    {
                        "name": "untrapped",
                        "lines": 13
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 44,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "sigtrap - Perl pragma to enable simple signal handling\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use sigtrap;\nuse sigtrap qw(stack-trace old-interface-signals);  # equivalent\nuse sigtrap qw(BUS SEGV PIPE ABRT);\nuse sigtrap qw(die INT QUIT);\nuse sigtrap qw(die normal-signals);\nuse sigtrap qw(die untrapped normal-signals);\nuse sigtrap qw(die untrapped normal-signals\nstack-trace any error-signals);\nuse sigtrap 'handler' => \\&myhandler, 'normal-signals';\nuse sigtrap qw(handler myhandler normal-signals\nstack-trace error-signals);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The sigtrap pragma is a simple interface to installing signal handlers.  You can have it\ninstall one of two handlers supplied by sigtrap itself (one which provides a Perl stack trace\nand one which simply \"die()\"s), or alternately you can supply your own handler for it to\ninstall.  It can be told only to install a handler for signals which are either untrapped or\nignored.  It has a couple of lists of signals to trap, plus you can supply your own list of\nsignals.\n\nThe arguments passed to the \"use\" statement which invokes sigtrap are processed in order.\nWhen a signal name or the name of one of sigtrap's signal lists is encountered a handler is\nimmediately installed, when an option is encountered it affects subsequently installed\nhandlers.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "SIGNAL HANDLERS\nThese options affect which handler will be used for subsequently installed signals.\n",
                "subsections": [
                    {
                        "name": "stack-trace",
                        "content": "The handler used for subsequently installed signals outputs a Perl stack trace to STDERR\nand then tries to dump core.  This is the default signal handler.\n\ndie The handler used for subsequently installed signals calls \"die\" (actually \"croak\") with a\nmessage indicating which signal was caught.\n\nhandler your-handler\nyour-handler will be used as the handler for subsequently installed signals.  your-\nhandler can be any value which is valid as an assignment to an element of %SIG. See\nperlvar for examples of handler functions.\n\nSIGNAL LISTS\nsigtrap has a few built-in lists of signals to trap.  They are:\n"
                    },
                    {
                        "name": "normal-signals",
                        "content": "These are the signals which a program might normally expect to encounter and which by\ndefault cause it to terminate.  They are HUP, INT, PIPE and TERM.\n"
                    },
                    {
                        "name": "error-signals",
                        "content": "These signals usually indicate a serious problem with the Perl interpreter or with your\nscript.  They are ABRT, BUS, EMT, FPE, ILL, QUIT, SEGV, SYS and TRAP.\n"
                    },
                    {
                        "name": "old-interface-signals",
                        "content": "These are the signals which were trapped by default by the old sigtrap interface, they\nare ABRT, BUS, EMT, FPE, ILL, PIPE, QUIT, SEGV, SYS, TERM, and TRAP.  If no signals or\nsignals lists are passed to sigtrap, this list is used.\n\nFor each of these three lists, the collection of signals set to be trapped is checked before\ntrapping; if your architecture does not implement a particular signal, it will not be trapped\nbut rather silently ignored.\n\nOTHER"
                    },
                    {
                        "name": "untrapped",
                        "content": "This token tells sigtrap to install handlers only for subsequently listed signals which\naren't already trapped or ignored.\n\nany This token tells sigtrap to install handlers for all subsequently listed signals.  This\nis the default behavior.\n\nsignal\nAny argument which looks like a signal name (that is, \"/^[A-Z][A-Z0-9]*$/\") indicates\nthat sigtrap should install a handler for that name.\n\nnumber\nRequire that at least version number of sigtrap is being used.\n"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "Provide a stack trace for the old-interface-signals:\n\nuse sigtrap;\n\nDitto:\n\nuse sigtrap qw(stack-trace old-interface-signals);\n\nProvide a stack trace on the 4 listed signals only:\n\nuse sigtrap qw(BUS SEGV PIPE ABRT);\n\nDie on INT or QUIT:\n\nuse sigtrap qw(die INT QUIT);\n\nDie on HUP, INT, PIPE or TERM:\n\nuse sigtrap qw(die normal-signals);\n\nDie on HUP, INT, PIPE or TERM, except don't change the behavior for signals which are already\ntrapped or ignored:\n\nuse sigtrap qw(die untrapped normal-signals);\n\nDie on receipt one of an of the normal-signals which is currently untrapped, provide a stack\ntrace on receipt of any of the error-signals:\n\nuse sigtrap qw(die untrapped normal-signals\nstack-trace any error-signals);\n\nInstall myhandler() as the handler for the normal-signals:\n\nuse sigtrap 'handler', \\&myhandler, 'normal-signals';\n\nInstall myhandler() as the handler for the normal-signals, provide a Perl stack trace on\nreceipt of one of the error-signals:\n\nuse sigtrap qw(handler myhandler normal-signals\nstack-trace error-signals);\n\n\n\nperl v5.34.0                                 2025-07-25                               sigtrap(3perl)",
                "subsections": []
            }
        }
    }
}