-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-35537: Add setsid parameter to os.posix_spawn() and os.posix_spawnp(). #11608
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a test. You can copy and adapt the test_subprocess test:
def test_start_new_session(self):
# For code coverage of calling setsid(). We don't care if we get an
# EPERM error from it depending on the test execution environment, that
# still indicates that it was called.
try:
output = subprocess.check_output(
[sys.executable, "-c",
"import os; print(os.getpgid(os.getpid()))"],
start_new_session=True)
except OSError as e:
if e.errno != errno.EPERM:
raise
else:
parent_pgid = os.getpgid(os.getpid())
child_pgid = int(output)
self.assertNotEqual(parent_pgid, child_pgid)
Misc/NEWS.d/next/Library/2019-01-18-13-44-13.bpo-35537.R1lbTl.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Misc/NEWS.d/next/Library/2019-01-18-13-44-13.bpo-35537.R1lbTl.rst
Outdated
Show resolved
Hide resolved
Modules/posixmodule.c
Outdated
PyObject *setsigdef, PyObject *scheduler, | ||
posix_spawnattr_t *attrp) | ||
{ | ||
const char *function_name = "posix_spawn"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's wrong: parse_posix_spawn_flags() is called from py_posix_spawnp(), so function_name should be "posix_spawnp" in that case. You have to add a parameter to parse_posix_spawn_flags().
nitpick: I suggest to rename the variable to "func_name".
a34eedc
to
225ff47
Compare
225ff47
to
6a93484
Compare
@vstinner I made some changes . PTAL. |
@nanjekyejoannah @vstinner Um, some of my comments were marked as resolved without addressing them, in particular, about shadowing the standard function with |
Oh, I didn't notice that. According to the GitHub UI, I was the only one who "requested changes" (voted -1 on the PR). I proposed to @nanjekyejoannah to reuse test_start_new_session() from test_subprocess. The comment of this test mentions setsid(). The 'start_new_session' parameter of subprocess.Popen becomes the 'call_setsid' parameter of _posixsubprocess.fork_exec() which then calls setsid(). If os.getpgid() is not appropriate: test_subprocess should be fixed as well. |
|
Thanks and congrats @nanjekyejoannah, I merged your PR! I saw that almost all my requests have been addressed exception of 'func_name': you added func_name but its value is hardcoded to "posix_spawnp". I started to write a fix, but then I saw other minor issues in error messages. So I wrote PR #11719 directly instead. I'm fine with working step by step, not having the perfect commit directly. Sadly, when I testing my "func_name" change, I noticed that "test_posix" fails locally. Oh. Why Travis CI didn't detect it? Oh. Now I recall that Travis CI lacks the required constant and so the test is skipped (NotImplementedError...). I wrote PR #11718 just to skip the test, to have more time to fix the test. This PR was awaiting for 2 weeks and got many reviews. I chose to merge it to make progress ;-) |
|
Ah, I see. I prefer to leave simple comments so that they are not mixed with reviews by core devs, but my approach backfired in this case.
While I think that technically the existing |
@vstinner I opened https://bugs.python.org/issue35876 after seeing the buildbot failures to track the failing test fixes. |
I have added a new setsid parameter to os.posix_spawnp() and os.posix_spawn().
I have not yet added a test for this.
@vstinner we can discuss this once you think this patch is good enough.
https://bugs.python.org/issue35537