-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
system() always returns -1 if process exits due to signal #205
Comments
juster
added a commit
to juster/goawk
that referenced
this issue
Aug 27, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Aug 27, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Aug 27, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Aug 29, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Aug 30, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Sep 1, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Sep 1, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Sep 10, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
juster
added a commit
to juster/goawk
that referenced
this issue
Sep 17, 2023
Old behavior always returned -1 on a signal exit. Fixes benhoyt#205
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another incompatible feature of awks is the return value of
system()
when death by signal is involved. The POSIX standard stipulates that the results of awk'ssystem()
should be the value of C'ssystem(3)
(which is the value ofwaitpid(2)
). But due to possible human error the value of awk'ssystem()
on signal exit was originally a fraction! This is C'swaitpid(2)
result divided by 256.The source here is goawk's
system()
docs:Example test command
awk variant output
waitpid()
Summary
There is no right answer. You could be the first awk to implement the POSIX standard ;) but I would suggest following gawk's example.
Another nice thing gawk did was to make the result the same as
close()
on a command pipe. Original awk behavior isn't terrible here but it forgets to matchsystem()
with theclose()
on a pipe. This may be due to the fact that using theclose()
result on pipe was not implemented in original awk.I stumbled across this when matching gawk's behavior for #203. I will make both
close(pipe)
andsystem()
match gawk's result in my forked branch, for now.The text was updated successfully, but these errors were encountered: