unbuffer is able to pass along the return code of a process under normal circumstance, but if the process you are unbuffering is killed, for instance with a segfault, I see $? as 0 while I expect 139. How can I get it to pass along the 139?

e.g. if I unbuffer a bash script that has simply exit 1, I get $? as 1. If I unbuffer a bash script that has kill -11 $$, I get 0.

unbuffer is actually just an expect script that comes with expect, but I don't know it well enough to decifer why the return code is not passed along.

  • 2
    I think i figured out why unbuffer doesn't work, but it requires writing a new wrapper. I don't think it can work as is. The expect wait command returns more arguments if the spawned process is killed but unbuffer just always returns the 3rd argument. I added a check to see if the 4th arg is CHILDKILLED to at least propigate a non-zero exit code in that case and that is enough for my purposes
    – frankc
    Aug 27, 2014 at 15:20
  • 1
    You should provide an answer to your own question, and accept it. Aug 27, 2014 at 15:40


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.