Skip to main content
added 83 characters in body
Source Link
l0b0
  • 53.6k
  • 48
  • 225
  • 398

ping will print more than one line. Since head -n 1 exits after the first line has been printed, and sends SIGPIPE to the writer (xargs will receive SIGPIPE, meaning that it's pointless for it) to continue running sincesay that there's nothingno process left to read whatwhatever it printswrites. It thereforeIn response xargs does what most processes do and kills its subprocesses (ping), prints thea warning, probably sends SIGPIPE to its own parent, and then kills itself. But if you check the actual exit code it is zero

You'll notice, becausehowever, that since you haven't set pipefail in your script the exit code of the full script is zero - the exit code of the sed command.

ping will print more than one line. Since head -n 1 exits after the first line has been printed xargs will receive SIGPIPE, meaning that it's pointless for it to continue running since there's nothing to read what it prints. It therefore prints the warning. But if you check the actual exit code it is zero, because you haven't set pipefail in your script.

head -n 1 exits after the first line has been printed, and sends SIGPIPE to the writer (xargs) to say that there's no process left to read whatever it writes. In response xargs does what most processes do and kills its subprocesses (ping), prints a warning, probably sends SIGPIPE to its own parent, and then kills itself.

You'll notice, however, that since you haven't set pipefail in your script the exit code of the full script is zero - the exit code of the sed command.

Source Link
l0b0
  • 53.6k
  • 48
  • 225
  • 398

ping will print more than one line. Since head -n 1 exits after the first line has been printed xargs will receive SIGPIPE, meaning that it's pointless for it to continue running since there's nothing to read what it prints. It therefore prints the warning. But if you check the actual exit code it is zero, because you haven't set pipefail in your script.