I'm trying to write a different shell command line interface where the input line stays at the top. Output of previous commands should stack below:


LAST OUTPUT (of command 1)



I want to use a non interactive bash process and would like to handle the insertion of the output into the process buffer via an output filter. Commands are send to the bash process via process-send-string.

As I tested the output of a command can arrive in chunks and I would like to know when all output has arrived because later I want to add features for which I need to know that (specifically I want to narrow the buffer after all output arrived).

So is it possible to determine when the the last chunk of output arrives the process filter?

Any answers explaining that this is totally the wrong way and what I should do instead are welcome, too!

  • (elisp) Sentinels perhaps? – npostavs Aug 21 '19 at 0:59
  • @npostavs I tried but the bash process doesn't emit any status change signals when executing commands. – clemera Aug 21 '19 at 6:33
  • @npostavs Your comment brought me to the idea to append (format "; kill -s STOP %s" pid) to the command string send to bash. Later I continue the process via continue-process. That works! – clemera Aug 21 '19 at 7:24
  • Ah, it's a bit unclear in the question what the nature of the bash process is. – npostavs Aug 21 '19 at 11:22
  • @npostavs I added this approach as an answer. – clemera Aug 21 '19 at 13:31

One way I discovered is to construct the command send to the bash process in such a way that after the execution the bash process gets stopped:

(format "%s; kill -s STOP %s\n" command (process-id bash-process))

This way a process-sentinel can be used to detect when the execution is done and can enable the process again:

(defun sentinel (proc status)
  (when (string= status "stopped (signal)\n")
    (continue-process proc)))

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.