[Interest] QProcess when ^Z is called

Scott Bloom scott at towel42.com
Fri Feb 11 03:00:35 CET 2022

Interesting, we are not seeing them go to sleep, simply by looking at the results we see them continue.

Ill take a look and create a sample, but it was a pretty straight forward qrocess->start() after setup type call.


-----Original Message-----
From: Thiago Macieira <thiago.macieira at intel.com> 
Sent: Thursday, February 10, 2022 5:58 PM
To: interest at qt-project.org
Cc: Scott Bloom <scott at towel42.com>
Subject: Re: [Interest] QProcess when ^Z is called

On Thursday, 10 February 2022 16:41:48 PST Scott Bloom wrote:
> I have an issue, that if the customer hits Ctrl-Z after the executable 
> is running, but has spawned a subprocess via QProcess, when the system 
> is restarted (either in the background or foreground), the QProcess 
> finished signal is lost.
> Im assuming the OS level signal of sleep/wake cant be monitored while 
> the application is a sleep.
> Is there any known solution to this?

This goes into an area of process support I have yet to completely understand: 
controlling terminals, process groups and session leaders. Ctrl+Z indicates you're running from the shell, with job control active, which probably means your Qt process is the session leader. Ctrl+Z would have suspended all processes in the group. See:

$ (sleep 10s & read)
[1]  + 400272 suspended  ( sleep 10s & read; ) ... wait more than 10 seconds ...
$ ps ft$TTY
  33201 pts/7    Ss     0:02 /bin/zsh
 400272 pts/7    T      0:00  \_ /bin/zsh
 400273 pts/7    T      0:00  |   \_ sleep 10s
 400338 pts/7    R+     0:00  \_ ps ft/dev/pts/7

That means the child process can't exit with just what you described, because the child is stopped alongside everything else in that process group. There's something more to your problem that you need to describe.

In any case, a dead child should become a zombie until the parent process performs the wait() call on it. This is what happens if you continue the

$ killall -CONT sleep
$ ps ft$TTY          
  33201 pts/7    Ss     0:02 /bin/zsh
 400394 pts/7    T      0:00  \_ /bin/zsh
 400395 pts/7    Z      0:00  |   \_ [sleep] <defunct>
 400412 pts/7    R+     0:00  \_ ps ft/dev/pts/7

The parent process will receive the SIGCHLD and QProcess will emit finished() when it resumes.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering

More information about the Interest mailing list