Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    Interresting. GNU only but interresting, as that one will (probably) keep the original return code for the rest of the code to follow (ie, it doesn't replace it with "0" as the other answers do) Commented Sep 8, 2017 at 11:27
  • 2
    It returns 0 though if the command is killed. Commented Sep 8, 2017 at 11:42
  • 2
    @bishop, I agree 0 in those cases is less than ideal. But note that, there's no general agreement as to what to report when a command is killed by a signal. Returning 128+signal number is used by a few shells. You also see things like 256+signum or 384+signum or even signum/256 or signum/256+0.5 if a core was generated (actually the status returned by waitpid() divided by 256). Some would give a textual representation (likesigint or sigquit+core). Still probably worth discussing on the gnu.coreutils.bugs newsgroup I agree. Commented Sep 8, 2017 at 12:01
  • 3
    (actually time is not part of coreutils, it's a package on its own with its own bug mailing list ([email protected])) Commented Sep 8, 2017 at 12:17
  • 1
    @bishop, the system() of traditional awks like the one still maintained by Brian Kernighan (the k in awk) or the nawk of Solaris, the awk of FreeBSD that derive from that. awk 'BEGIN{print system("kill -s ABRT $$")}' outputs 0.523438 when the core dump size is not limited. The behaviour of gawk has changed recently, with varying behaviour with --traditional or --posix (see also the return value of close(cmd) for more variation) Commented Sep 8, 2017 at 13:47