Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions ptyprocess/ptyprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,25 @@ def isalive(self):
except OSError as e:
# No child processes
if e.errno == errno.ECHILD:
raise PtyProcessError('isalive() encountered condition ' +
'where "terminated" is 0, but there was no child ' +
'process. Did someone else call waitpid() ' +
'on our process?')
try:
os.kill(self.pid, 0)
except OSError as err:
if err.errno == errno.ESRCH:
# No such process
raise PtyProcessError('isalive() encountered condition ' +
'where "terminated" is 0, but there was no child ' +
'process. Did someone else call waitpid() ' +
'on our process?')
elif err.errno == errno.EPERM:
# Process deny access
raise PtyProcessError('isalive() encountered condition ' +
'where the child process deny access')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

raise PtyProcessError('isalive() does not have permission to query the process')

else:
# Other possible error
raise err
else:
# Process exists not as child
pid, status = 0, 0
else:
raise

Expand All @@ -717,10 +732,25 @@ def isalive(self):
except OSError as e: # pragma: no cover
# This should never happen...
if e.errno == errno.ECHILD:
raise PtyProcessError('isalive() encountered condition ' +
'that should never happen. There was no child ' +
'process. Did someone else call waitpid() ' +
'on our process?')
try:
os.kill(self.pid, 0)
except OSError as err:
if err.errno == errno.ESRCH:
# No such process
raise PtyProcessError('isalive() encountered condition ' +
'where "terminated" is 0, but there was no child ' +
'process. Did someone else call waitpid() ' +
'on our process?')
elif err.errno == errno.EPERM:
# Process deny access
raise PtyProcessError('isalive() encountered condition ' +
'where the child process deny access')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

raise PtyProcessError('isalive() does not have permission to query the process')

else:
# Other possible error
raise err
else:
# Process exists not as child
pid, status = 0, 0
else:
raise

Expand Down