pipx run isn't redirecting signals to child app (?)
See original GitHub issueHello,
What a wonderful tool, no more manual management of python apps in my system 😃
About the issue, I wonder if signals are being redirected to the child app when calling pipx run <app>. For instance:
pipx run --spec tmonpy tmon
tmon in the absence of arguments, waits for SIGINT to return and print a temperature report. But it looks like pipx run when SIGINT-ed kills the app and doesn’t give it a chance to return gracefully (I could be wrong though, I haven’t looked at the source).
So this is what I would expect to happen:
pipx run --spec tmonpy tmon
wait a few seconds, press Ctrl+C and a graph should be printed in the terminal:
===================
Temp Monitor Report
temp (°C) for a period of 0:00:04
41.00 ┤
40.86 ┤
40.71 ┤
40.57 ┤
40.43 ┤
40.29 ┤
40.14 ┤
40.00 ┼╮
39.86 ┤│
39.71 ┤│
39.57 ┤│
39.43 ┤│
39.29 ┤│
39.14 ┤│
39.00 ┤╰───
min: 39.1 °C
avg: 39.2 °C
max: 40.0 °C
raw: /tmp/tmon-20200926@19h56m17-c1jxq4s6.txt
===================
Note: tmon is expected to work on Linux only! Don’t try to run the test case on mac or win.
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (15 by maintainers)
Top Results From Across the Web
pipx run isn't redirecting signals to child app (?) #506 - GitHub
We use subprocess.run() to run your pipx run script, and we do not supply a stdin argument, which should mean that stdin is...
Read more >pipx — Install and Run Python Applications in Isolated ...
If so, go to the mentioned folder, allowing you to run the pipx executable directly. Enter the following line (even if you did...
Read more >How to redirect signal to child process from parent process?
Try it in a shell - start some process, then press Ctrl-Z. Now hit fg and enter - the process will continue where...
Read more >pybind11 Documentation - Read the Docs
pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python.
Read more >TS 133 501 - V16.9.1 - 5G - ETSI
The content of the PDF version shall not be modified without the written authorization of ETSI. ... Rules on concurrent running of security...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Windows and Unix-like systems implement
exec*stuff differently. On POSIX, the process is first forked, and then the new program is loaded into the (forked) process. Windows does not havefork, so the implementation basically starts a new process in the background, and exits the current process. This is fine for Windows (the subsystem, not the operating system) applications, but has some unexpected (to people familiar with the fork-based implementation) behaviours when used in the console subsystem. You can try this in cmd.exe:You can see a prompt being displayed before the version information, because the process launched with
os.execlis in the background, and you get dropped back to the shell when the former process exits. This causes more problems when you need to interact with the launched process:Since the new process is in the background, and the user is dropped back to the shell, all inputs now goes to the shell, not the launched process.
Rule of thumb: Don’t use the
exec*family on Windows in a console application. It never does what you want.os.exec*(which calls into the correspondingexec*C functions) “swaps out” the current process entirely, so the current process (which is running pytest) just vanishes in thin air when you call that. This is done at the OS level, thus not possible to verify with pytest. The best thing you can do is to mock it out and verify the arguments.