Skip to content

Commit 2eba6ad

Browse files
corona10serhiy-storchaka
authored andcommitted
bpo-38493: Add os.CLD_KILLED and os.CLD_STOPPED. (pythonGH-16821)
1 parent a9ed91e commit 2eba6ad

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

Doc/library/os.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,8 +3946,10 @@ written in Python, such as a mail server's external command delivery program.
39463946

39473947

39483948
.. data:: CLD_EXITED
3949+
CLD_KILLED
39493950
CLD_DUMPED
39503951
CLD_TRAPPED
3952+
CLD_STOPPED
39513953
CLD_CONTINUED
39523954

39533955
These are the possible values for :attr:`si_code` in the result returned by
@@ -3957,6 +3959,9 @@ written in Python, such as a mail server's external command delivery program.
39573959

39583960
.. versionadded:: 3.3
39593961

3962+
.. versionchanged:: 3.9
3963+
Added :data:`CLD_KILLED` and :data:`CLD_STOPPED` values.
3964+
39603965

39613966
.. function:: waitpid(pid, options)
39623967

Doc/whatsnew/3.9.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ that schedules a shutdown for the default executor that waits on the
125125
:func:`asyncio.run` has been updated to use the new :term:`coroutine`.
126126
(Contributed by Kyle Stanley in :issue:`34037`.)
127127

128+
os
129+
__
130+
131+
Added :data:`~os.CLD_KILLED` and :data:`~os.CLD_STOPPED` for :attr:`si_code`.
132+
(Contributed by Dong-hee Na in :issue:`38493`.)
133+
128134
threading
129135
---------
130136

Lib/test/test_posix.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,16 @@ def test_rename_dir_fd(self):
12261226
finally:
12271227
posix.close(f)
12281228

1229+
@unittest.skipUnless(hasattr(signal, 'SIGCHLD'), 'CLD_XXXX be placed in si_code for a SIGCHLD signal')
1230+
@unittest.skipUnless(hasattr(os, 'waitid_result'), "test needs os.waitid_result")
1231+
def test_cld_xxxx_constants(self):
1232+
os.CLD_EXITED
1233+
os.CLD_KILLED
1234+
os.CLD_DUMPED
1235+
os.CLD_TRAPPED
1236+
os.CLD_STOPPED
1237+
os.CLD_CONTINUED
1238+
12291239
@unittest.skipUnless(os.symlink in os.supports_dir_fd, "test needs dir_fd support in os.symlink()")
12301240
def test_symlink_dir_fd(self):
12311241
f = posix.open(posix.getcwd(), posix.O_RDONLY)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added :data:`~os.CLD_KILLED` and :data:`~os.CLD_STOPPED` for :attr:`si_code`.
2+
Patch by Dong-hee Na.

Modules/posixmodule.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14057,12 +14057,18 @@ all_ins(PyObject *m)
1405714057
#ifdef CLD_EXITED
1405814058
if (PyModule_AddIntMacro(m, CLD_EXITED)) return -1;
1405914059
#endif
14060+
#ifdef CLD_KILLED
14061+
if (PyModule_AddIntMacro(m, CLD_KILLED)) return -1;
14062+
#endif
1406014063
#ifdef CLD_DUMPED
1406114064
if (PyModule_AddIntMacro(m, CLD_DUMPED)) return -1;
1406214065
#endif
1406314066
#ifdef CLD_TRAPPED
1406414067
if (PyModule_AddIntMacro(m, CLD_TRAPPED)) return -1;
1406514068
#endif
14069+
#ifdef CLD_STOPPED
14070+
if (PyModule_AddIntMacro(m, CLD_STOPPED)) return -1;
14071+
#endif
1406614072
#ifdef CLD_CONTINUED
1406714073
if (PyModule_AddIntMacro(m, CLD_CONTINUED)) return -1;
1406814074
#endif

0 commit comments

Comments
 (0)