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

Exec from signal handler terminates the process itself #1019

Open
mil opened this issue Nov 24, 2021 · 1 comment
Open

Exec from signal handler terminates the process itself #1019

mil opened this issue Nov 24, 2021 · 1 comment

Comments

@mil
Copy link

mil commented Nov 24, 2021

In bash/ash/dash, if you run exec $0 from within a signal handler things work fine and run in an infinite loop as they should:

#!/usr/bin/env osh
trap hup HUP

hup() {
  echo "hup handler"
  exec $0
}

main() {
  {
    echo subproc start
    sleep 1
    kill -HUP 0
  } &

  echo mainproc
  sleep 999
}

main

In osh, this same script just terminates immediately at exec $0.

@andychu
Copy link
Contributor

andychu commented Jan 30, 2022

Sorry for not responding to this. Does this break a program or did you find this through testing?

I just published a post that is largely about signal handlers, so maybe this new model will help with this difference ...

http://www.oilshell.org/blog/2022/01/notes-themes.html

But I can't think of a reason someone would want this, so it's probably low priority ...

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

No branches or pull requests

2 participants