0

I have a (Linux) PyQt5 application with some widgets (buttons and input fields) and a QProcess object. I start the process by launching an rxvt(1) terminal emulator and feeding it the program that I want to execute. Something like this

winIdStr = str(int(self.term.winId()))
cmd = 'rxvt'
cmdOpts = []
cmdOpts.append('-bg'); cmdOpts.append('#5D6D7E')
cmdOpts.append('-fg'); cmdOpts.append('white')
cmdOpts.append('-embed'); cmdOpts.append(winIdStr)
cmdOpts.append('-e'); cmdOpts.append('./goo')
cmdOpts.append(count)
self.process.start(cmd, cmdOpts)
print(self.process.exitCode())

This is functionally working fine. However I need to make the following enhancements:

  1. Currently rxvt(1) exits when program (goo) runs to completion. I need to keep the rxvt around. I think there are multiple ways to do this. A) some terminal emulators allow a flag to keep the window. I could not find such a flag for rxvt. So if you know it, that would be nice. B) Perhaps QProcess has a property that keeps the window around. C) Have QProcess launch goo_guardian(1) which will then fork and exec goo(1) and will not exit. Sort of like a pause in DOS.
  2. I need to monitor this external process. I need to know if it is running, its process ID (in case it is wedged and I need to kill it). 2.1) I think the previous 1.C solution (with a guardian), can help me with this.

Any help from PyQt5 community is appreciated. FYI, target OS is Linux.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Medi Montaseri
  • 115
  • 3
  • 14
  • What is the purpose of executing the command in rxvt? Why not just capture the output directly? – ekhumoro Nov 19 '19 at 20:29
  • The sub-process (goo) is an interactive program. I could not find an easy way of piping with stdin, stdout and stderr of sub-process. Further python read functions seems to operated in cooked mode (line oriented) and not raw (char by char), hence this approach. ie start an embedded terminal. – Medi Montaseri Nov 19 '19 at 20:50
  • Would the `-pty-fd` option help? See [here](https://stackoverflow.com/q/14772138/984421). – ekhumoro Nov 19 '19 at 21:16
  • Passing a descriptor to xterm/rxvt takes me down the path of becoming intimate with the sub-process in terms of its input/output needs. Frankly I don't give me damn....sorry that was from the Gone with the wind movie ... all I need is a process monitoring (kind of a macro supervision). I did think of a named pipe hookup between my application and guardian. Lets see how ugly that gets... – Medi Montaseri Nov 19 '19 at 21:31
  • No, the idea is to run rxvt without any initial command, and then communicate with it via the slave. I'm assuming that will keep it open and allow you to get information about and/or control any processes it has started. – ekhumoro Nov 19 '19 at 21:37

0 Answers0