Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job status not updated on SIGSTOP/SIGCONT #174

Open
caseman opened this issue Nov 13, 2020 · 1 comment
Open

Job status not updated on SIGSTOP/SIGCONT #174

caseman opened this issue Nov 13, 2020 · 1 comment

Comments

@caseman
Copy link

caseman commented Nov 13, 2020

build/mrsh -mb
$ sleep 100&
$ kill -STOP $(pidof sleep)
$ jobs
[1] + Running sleep 100 &
$ kill $(pidof sleep)
$ 
[1] + Done(33024) sleep 100 &

The problem seems to be here:

if (!priv->child) {

This check doesn't make sense to me, I would think you would only want to check WUNTRACED for children, since checking it for the parent shell process seems useless, but maybe I'm missing something. Also in order to detect SIGCONT the option WCONTINUED would need to be used where available, something like:

#ifdef WCONTINUED
               options |= WUNTRACED | WCONTINUED;
#else
               options |= WUNTRACED;
#endif

Although maybe that check is too pedantic, I'm not sure if any major platforms lack support for WCONTINUED today.

Happy to make a PR but I feel like I don't understand the intention of the check unless priv->child is supposed to mean something different than I'm thinking, is it only supposed to be set for grandchildren?

@caseman
Copy link
Author

caseman commented Nov 13, 2020

What I have learned so far:

  • Inverting the check if (!priv->child) { above alone causes the job to exit if you send the worker process (e.g., sleep) SIGSTOP. You can prevent this by not returning here if priv-child is true:

    return true;

  • The job still does not report its status properly though if you send SIGSTOP to sleep because the sleep (grand)child process itself is not tracked in the job (edit: it is added, but presumably that happens inside the background child, so it isn't actually tracked). However simply tracking it would not help because the job reports "running" if any of its child processes are running, and the main job process (child of mrsh, parent of sleep worker) is always running.

I'm assuming the intermediate job process is a simplification somehow, other shells like zsh don't use one. But regardless of that it doesn't seem useful to report the job status based on the status of that process, other than when it exits entirely perhaps. I'll keep exploring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant