bpo-28206: Document signals Handlers, Sigmasks and Signals enums (GH-… · python/cpython@9be930f (original) (raw)

`@@ -68,10 +68,34 @@ Module contents

`

68

68

`` signal (SIG*), handler (:const:SIG_DFL, :const:SIG_IGN) and sigmask

``

69

69

`` (:const:SIG_BLOCK, :const:SIG_UNBLOCK, :const:SIG_SETMASK)

``

70

70

` related constants listed below were turned into

`

71

``

`` -

:class:enums <enum.IntEnum>.

``

``

71

`` +

:class:enums <enum.IntEnum> (:class:Signals, :class:Handlers and :class:Sigmasks respectively).

``

72

72

`` :func:getsignal, :func:pthread_sigmask, :func:sigpending and

``

73

73

`` :func:sigwait functions return human-readable

``

74

``

`` -

:class:enums <enum.IntEnum>.

``

``

74

`` +

:class:enums <enum.IntEnum> as :class:Signals objects.

``

``

75

+

``

76

+

``

77

`+

The signal module defines three enums:

`

``

78

+

``

79

`+

.. class:: Signals

`

``

80

+

``

81

`` +

:class:enum.IntEnum collection of SIG* constants and the CTRL_* constants.

``

``

82

+

``

83

`+

.. versionadded:: 3.5

`

``

84

+

``

85

`+

.. class:: Handlers

`

``

86

+

``

87

`` +

:class:enum.IntEnum collection the constants :const:SIG_DFL and :const:SIG_IGN.

``

``

88

+

``

89

`+

.. versionadded:: 3.5

`

``

90

+

``

91

`+

.. class:: Sigmasks

`

``

92

+

``

93

`` +

:class:enum.IntEnum collection the constants :const:SIG_BLOCK, :const:SIG_UNBLOCK and :const:SIG_SETMASK.

``

``

94

+

``

95

`` +

Availability: Unix. See the man page :manpage:sigprocmask(3) and

``

``

96

`` +

:manpage:pthread_sigmask(3) for further information.

``

``

97

+

``

98

`+

.. versionadded:: 3.5

`

75

99

``

76

100

``

77

101

`` The variables defined in the :mod:signal module are:

``

`` @@ -618,8 +642,8 @@ The :mod:signal module defines the following functions:

``

618

642

``

619

643

`.. _signal-example:

`

620

644

``

621

``

`-

Example

`

622

``

`-


`

``

645

`+

Examples

`

``

646

`+


`

623

647

``

624

648

`` Here is a minimal example program. It uses the :func:alarm function to limit

``

625

649

`the time spent waiting to open a file; this is useful if the file is for a

`

`@@ -631,7 +655,8 @@ be sent, and the handler raises an exception. ::

`

631

655

` import signal, os

`

632

656

``

633

657

` def handler(signum, frame):

`

634

``

`-

print('Signal handler called with signal', signum)

`

``

658

`+

signame = signal.Signals(signum).name

`

``

659

`+

print(f'Signal handler called with signal {signame} ({signum})')

`

635

660

` raise OSError("Couldn't open device!")

`

636

661

``

637

662

` # Set the signal handler and a 5-second alarm

`