Skip to content

Show error message when processes are killed by SIGSEGV/SIGILL/etc #12874

Description

@tgross35

Related problem

Nushell currently does not print anything when a program is terminated by a signal:

> echo "int main() { asm("ud2"); }" out> sigill.c
> gcc sigill.c -o sigill.out
> ./sigill.out
> # *crickets*
> echo "int main() { int v = *((int *)0x0); }" out> sigsegv.c
> gcc sigsegv.c -o sigsegv.out
> ./sigsegv.out
> # *crickets*

This could be okay if you have the exit code displayed as part of the prompt, but if you don't then it looks like everything completed successfully.

By contrast, Bash tells you what went wrong:

$ ./sigill.out
Illegal instruction
$ ./sigsegv.out
Segmentation fault

Describe the solution you'd like

If a signal is the reason a program exits prematurely, print the associated comment so the user is aware of the problem (available at https://man7.org/linux/man-pages/man7/signal.7.html "Standard signals" table), or the same for the Windows equivalent. This can be retrieved on nix with ExitStatusExt::signal.

Describe alternatives you've considered

No response

Additional context and details

No response

Activity

  1. added
    category:enhancement
    status:needs-triage
    on May 15, 2024
  2. sholderbach commented on May 15, 2024

    @sholderbach
    Member

    Related challenge #12369 (not a duplicate)

    @IanManske built some parts to potentially fix this in #12774 if I recall, I tried some things in #12370 but that did not work yet.

  3. added
    A:external-commands
    A:error-handling
    and removed
    status:needs-triage
    on May 15, 2024
  4. sholderbach commented on May 16, 2024

    @sholderbach
    Member

    With #12774 we now properly pull out the signal but don't report the error as mentioned here (I think we had code for that at some point.) The $env.LAST_EXIT_CODE contains the signal value in negated form (which I think is not the conventional form. If I recall on Linux it is signal value + 128?)

  5. tgross35 commented on May 16, 2024

    @tgross35
    Author

    Does nushell not use std::process::Command? If so, the signal is available with .signal() under the ExitSignalExt trait (which calls libc::WIFSIGNALED(self.0).then(|| libc::WTERMSIG(self.0)) internally)

  6. added this to the v0.95.0 milestone on Jun 7, 2024
  7. IanManske commented on Jun 22, 2024

    @IanManske
    Member

    #13034 only handles core dumps, not signals in general.

  8. removed this from the v0.95.0 milestone on Jun 24, 2024
  9. added a commit that references this issue on Sep 7, 2024
    3d008e2
  10. added this to the v0.98.0 milestone on Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-handlingA:external-commandscategory:enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions