Skip to content

Exec from signal handler terminates the process itself #1019

Open
@mil

Description

@mil

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions