@@ -5166,10 +5166,11 @@ convert_sched_param(PyObject *param, struct sched_param *res);
5166
5166
#endif
5167
5167
5168
5168
static int
5169
- parse_posix_spawn_flags (PyObject * setpgroup , int resetids , PyObject * setsigmask ,
5169
+ parse_posix_spawn_flags (PyObject * setpgroup , int resetids , int setsid , PyObject * setsigmask ,
5170
5170
PyObject * setsigdef , PyObject * scheduler ,
5171
5171
posix_spawnattr_t * attrp )
5172
5172
{
5173
+ const char * func_name = "posix_spawnp" ;
5173
5174
long all_flags = 0 ;
5174
5175
5175
5176
errno = posix_spawnattr_init (attrp );
@@ -5195,6 +5196,17 @@ parse_posix_spawn_flags(PyObject *setpgroup, int resetids, PyObject *setsigmask,
5195
5196
all_flags |= POSIX_SPAWN_RESETIDS ;
5196
5197
}
5197
5198
5199
+ if (setsid ) {
5200
+ #ifdef POSIX_SPAWN_SETSID
5201
+ all_flags |= POSIX_SPAWN_SETSID ;
5202
+ #elif defined(POSIX_SPAWN_SETSID_NP )
5203
+ all_flags |= POSIX_SPAWN_SETSID_NP ;
5204
+ #else
5205
+ argument_unavailable_error (func_name , "setsid" );
5206
+ return -1 ;
5207
+ #endif
5208
+ }
5209
+
5198
5210
if (setsigmask ) {
5199
5211
sigset_t set ;
5200
5212
if (!_Py_Sigset_Converter (setsigmask , & set )) {
@@ -5385,7 +5397,7 @@ parse_file_actions(PyObject *file_actions,
5385
5397
static PyObject *
5386
5398
py_posix_spawn (int use_posix_spawnp , PyObject * module , path_t * path , PyObject * argv ,
5387
5399
PyObject * env , PyObject * file_actions ,
5388
- PyObject * setpgroup , int resetids , PyObject * setsigmask ,
5400
+ PyObject * setpgroup , int resetids , int setsid , PyObject * setsigmask ,
5389
5401
PyObject * setsigdef , PyObject * scheduler )
5390
5402
{
5391
5403
EXECV_CHAR * * argvlist = NULL ;
@@ -5400,7 +5412,7 @@ py_posix_spawn(int use_posix_spawnp, PyObject *module, path_t *path, PyObject *a
5400
5412
pid_t pid ;
5401
5413
int err_code ;
5402
5414
5403
- /* posix_spawn has three arguments: (path, argv, env), where
5415
+ /* posix_spawn and posix_spawnp have three arguments: (path, argv, env), where
5404
5416
argv is a list or tuple of strings and env is a dictionary
5405
5417
like posix.environ. */
5406
5418
@@ -5455,7 +5467,7 @@ py_posix_spawn(int use_posix_spawnp, PyObject *module, path_t *path, PyObject *a
5455
5467
file_actionsp = & file_actions_buf ;
5456
5468
}
5457
5469
5458
- if (parse_posix_spawn_flags (setpgroup , resetids , setsigmask ,
5470
+ if (parse_posix_spawn_flags (setpgroup , resetids , setsid , setsigmask ,
5459
5471
setsigdef , scheduler , & attr )) {
5460
5472
goto exit ;
5461
5473
}
@@ -5519,7 +5531,9 @@ os.posix_spawn
5519
5531
setpgroup: object = NULL
5520
5532
The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.
5521
5533
resetids: bool(accept={int}) = False
5522
- If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.
5534
+ If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.
5535
+ setsid: bool(accept={int}) = False
5536
+ If the value is `true` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.
5523
5537
setsigmask: object(c_default='NULL') = ()
5524
5538
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
5525
5539
setsigdef: object(c_default='NULL') = ()
@@ -5533,12 +5547,13 @@ Execute the program specified by path in a new process.
5533
5547
static PyObject *
5534
5548
os_posix_spawn_impl (PyObject * module , path_t * path , PyObject * argv ,
5535
5549
PyObject * env , PyObject * file_actions ,
5536
- PyObject * setpgroup , int resetids , PyObject * setsigmask ,
5537
- PyObject * setsigdef , PyObject * scheduler )
5538
- /*[clinic end generated code: output=45dfa4c515d09f2c input=2891c2f1d457e39b]*/
5550
+ PyObject * setpgroup , int resetids , int setsid ,
5551
+ PyObject * setsigmask , PyObject * setsigdef ,
5552
+ PyObject * scheduler )
5553
+ /*[clinic end generated code: output=14a1098c566bc675 input=8c6305619a00ad04]*/
5539
5554
{
5540
5555
return py_posix_spawn (0 , module , path , argv , env , file_actions ,
5541
- setpgroup , resetids , setsigmask , setsigdef ,
5556
+ setpgroup , resetids , setsid , setsigmask , setsigdef ,
5542
5557
scheduler );
5543
5558
}
5544
5559
#endif /* HAVE_POSIX_SPAWN */
@@ -5563,6 +5578,8 @@ os.posix_spawnp
5563
5578
The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.
5564
5579
resetids: bool(accept={int}) = False
5565
5580
If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.
5581
+ setsid: bool(accept={int}) = False
5582
+ If the value is `True` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.
5566
5583
setsigmask: object(c_default='NULL') = ()
5567
5584
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
5568
5585
setsigdef: object(c_default='NULL') = ()
@@ -5576,12 +5593,13 @@ Execute the program specified by path in a new process.
5576
5593
static PyObject *
5577
5594
os_posix_spawnp_impl (PyObject * module , path_t * path , PyObject * argv ,
5578
5595
PyObject * env , PyObject * file_actions ,
5579
- PyObject * setpgroup , int resetids , PyObject * setsigmask ,
5580
- PyObject * setsigdef , PyObject * scheduler )
5581
- /*[clinic end generated code: output=7955dc0edc82b8c3 input=b7576eb25b1ed9eb]*/
5596
+ PyObject * setpgroup , int resetids , int setsid ,
5597
+ PyObject * setsigmask , PyObject * setsigdef ,
5598
+ PyObject * scheduler )
5599
+ /*[clinic end generated code: output=7b9aaefe3031238d input=c1911043a22028da]*/
5582
5600
{
5583
5601
return py_posix_spawn (1 , module , path , argv , env , file_actions ,
5584
- setpgroup , resetids , setsigmask , setsigdef ,
5602
+ setpgroup , resetids , setsid , setsigmask , setsigdef ,
5585
5603
scheduler );
5586
5604
}
5587
5605
#endif /* HAVE_POSIX_SPAWNP */
0 commit comments