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

documentation is confusing around exit codes #29

Closed
robx opened this issue Apr 7, 2020 · 7 comments
Closed

documentation is confusing around exit codes #29

robx opened this issue Apr 7, 2020 · 7 comments

Comments

@robx
Copy link

robx commented Apr 7, 2020

The man page states that entr exits with status code 0 on SIGINT, but it seems it does the right thing (?) instead and exits with 130.

Compare discussion here: https://lobste.rs/s/j9qfxm/entr_1_event_notify_test_runner#c_vxwtmi

The backstory is I ran into issue #19 while trying to watch for new files using the example while loop from the man page:

$ cat Makefile
watch:
        while true; do ls src/*.rb | entr -d make; done
@robx robx changed the title documentation is confusing around exit codes and while loops documentation is confusing around exit codes Apr 7, 2020
@robx
Copy link
Author

robx commented Apr 7, 2020

(Apologies for the incomplete first version of the issue, I hit some wrong keys.)

@eradman
Copy link
Owner

eradman commented Apr 8, 2020

You are right, after some cleanup entr raises the signal, so you will get the default return codes (130 for SIGINT, 143 for SIGTERM)

void
handle_exit(int sig) {
        if (!noninteractive_opt)
                xtcsetattr(0, TCSADRAIN, &canonical_tty);
        terminate_utility();
        raise(sig);
}

I'll first try to determine why I thought it should be 0.

@eradman
Copy link
Owner

eradman commented Apr 16, 2020

I think it make sense to change the documentation to reflect the current behavior. It seems that most unix utilities do not override the signal exit code

$ sleep 100
^C
$ echo $?
130

This means the only time entr would exit with 0 is using the new -z (one-shot) option.

@eradman
Copy link
Owner

eradman commented Apr 17, 2020

Thanks again @robx for writing a ticket on this topic. In commit 2741bd1 I made the following changes

  • SIGTERM or pressing q will return with exit code 0
  • The new -z option will return 0 if the utility was executed, or 1 if execution failed (permissions, non-existent path, etc.)

Other signals are use default handling

@robx
Copy link
Author

robx commented Apr 17, 2020

Thanks for looking into this! (And more importantly, making the tool in the first place.) Sounds like a reasonable fix.

@eradman
Copy link
Owner

eradman commented Apr 20, 2020

These adjustments were included in the newly minted 4.5 release

@eradman eradman closed this as completed Apr 20, 2020
@maiamcc
Copy link

maiamcc commented Oct 13, 2020

<comment deleted, I should just raise as a separate issue: see #53>

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

3 participants