Comments (13)
I have made a commit in my fork repo of ptyprocess
masteret@420f657
If it is ok to use please allow me to create a PR
from ptyprocess.
I also ran into this issue. It would be great if this issue can be fixed soon!
from ptyprocess.
Just wanted to point out another thing that we should consider when implementing the solution...
In the same scenario, if the child is closed, terminated, or killed by process B, it will become a zombie process (PID is still valid but the process is dead)... This os.kill(pid, 0) solution would not catch that since the return would be None, instead of an exception.
The use case is like this: 1) Process A created an child session 2) Process B is created by multiprocess and it uses the same child session 3) If Process B kills the child session that was created under process A, os.kill(pid, 0) will return None and isalive will return True.
from ptyprocess.
Won't Process A successfully call os.waitpid(self.pid, waitpid_options)
on the child?
from ptyprocess.
Yes, process A would be able to get the correct isalive() status with os.waitpid. However, if process B runs isalive check, it would run into the situation I described.
from ptyprocess.
I just verified this with some code. After Process B killed Process C, os.kill
did not raise an exception.
from ptyprocess.
Thank you for the comments, I will look into the scenario and see if I can check it correctly
from ptyprocess.
Perhaps @rocmit can make an helpful suggestion.
from ptyprocess.
Since process A can get a correct isalive() status with os.waitpid
The problem only happens when non-parent process call isalive with ptyprocess pid
I can add an additional check to see if the pid is a zombie process by looking at the 3rd item in /proc/${pid}/stat
if it is Z then that means the process is a zombie, then we can assume it is not alive
from ptyprocess.
There won't be a proc
file system on OS X.
from ptyprocess.
/proc/pid/stat file is what I use to workaround this after doing some research. Like MountainRider mentioned, this may not work on other OS.
from ptyprocess.
After some research, I found psutil has a way to determine if a proc is zombie in different os.
In Linux, it checks the proc and in OSX it uses sysctl in C.
from ptyprocess.
Yes, a maintainer here to chime in, the only thing preventing me from reviewing this PR quickly is to get FreeBSD, Linux, and mac machines to run the current tests--we may even need additional tests to cover new logic here, we'll see what the coverage report says, and/ or write some if-else conditions around platform if necessary.
from ptyprocess.
Related Issues (20)
- Incorrect distributive in WHEEL format HOT 1
- 0.5.2 not really released? HOT 1
- PtyProcess.spawn (and thus pexpect) is not safe for use in multithreaded applications HOT 6
- ptyprocess 0.5.1 and 0.5.2 appear to be missing the setup.py file. HOT 2
- Release? HOT 1
- is it possible to PtyProcess.read() without blocking? HOT 3
- PtyProcess.spawn (and thus pexpect) slowdown in close() loop HOT 2
- Rather than closing all the file descriptors, set close on exec on them HOT 3
- PtyProcess.spawn just got slower and can trigger problems HOT 2
- use os.posix_spawn when available (i.e, 3.8) HOT 4
- The preexec_fn should be executed before closing the file descriptors.
- Use stdin in child process HOT 12
- Release? HOT 1
- PtyProcess.read() returns a different value every call HOT 1
- pty cannot read unicode color escapde HOT 2
- The positions of the two arguments in setwinsize function appear to be reversed HOT 2
- test_spawn_sh occasionally fails
- Help to the xonsh shell HOT 6
- ptyprocess.read() does not read last two lines
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ptyprocess.