Skip to content
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

ForkedFunc raises EOFError if function exits with status 0 #261

Open
vermaport opened this issue Sep 30, 2020 · 0 comments · May be fixed by #262
Open

ForkedFunc raises EOFError if function exits with status 0 #261

vermaport opened this issue Sep 30, 2020 · 0 comments · May be fixed by #262

Comments

@vermaport
Copy link

waitfinish() assumes that if the forked child process exited with exitstatus == 0, that _child() ran to completion and wrote out the retval. This is not true if the function run in the child process hard exited with status 0, e.g. os._exit(0) (or even sys.exit(0)).

I added a new test for this and will submit a PR to fix the issue shortly.

=========================================================== FAILURES ============================================================
__________________________________________________________ test_exit0 ___________________________________________________________

    def test_exit0():
        def exit0():
            os._exit(0)
>       result = py.process.ForkedFunc(exit0).waitfinish()

testing/process/test_forkedfunc.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <py._process.forkedfunc.ForkedFunc object at 0x7f81dee546d8>, waiter = <built-in function waitpid>

    def waitfinish(self, waiter=os.waitpid):
        pid, systemstatus = waiter(self.pid, 0)
        if systemstatus:
            if os.WIFSIGNALED(systemstatus):
                exitstatus = os.WTERMSIG(systemstatus) + 128
            else:
                exitstatus = os.WEXITSTATUS(systemstatus)
        else:
            exitstatus = 0
        signal = systemstatus & 0x7f
        if not exitstatus and not signal:
            retval = self.RETVAL.open('rb')
            try:
                retval_data = retval.read()
            finally:
                retval.close()
>           retval = marshal.loads(retval_data)
E           EOFError: EOF read where object expected
@vermaport vermaport linked a pull request Sep 30, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant