Skip to content

ForkedFunc raises EOFError if function exits with status 0 #261

Description

@vermaport

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions