0

Currently I'm using make-process and it's stderr argument which is a buffer.

After the process has exited I'd like to check if the buffer-length is zero (no error output).

This doesn't work as I get an unhelpful Process *my-process* stderr finished.

Is there a way to get the stderr output of a process without additional text?

(besides searching for the string literal and stripping it out which seems over-complicated).


To give some context, I want to treat any error output as an error for the command I'm calling, as the exit-code isn't always a reliable way of checking if an error occurred.

1
  • Note that using cl-letf to override internal-default-process-sentinel can be used to remove the extra text (./test/lisp/net/tramp-tests.el in emacs repo does this), although I'd rather not have to override internal functions if there is a cleaner way to resolve.
    – ideasman42
    Apr 24 at 4:18

1 Answer 1

0

As far as I know there isn't a good way to prevent the Process *my-process* stderr finished text from being written into the the output (unless you count overriding internal functions *)

The only practical way I found to do this was to handle the stderr output in the processes sentinel function.

The length of the stderr buffer can be checked for zero, optionally its contents read into a string.

While not ideal (as it would be nice to have a way not to append the text in the first place), all things considered it seems the most practical option.


* internal-default-process-sentinel can be overridden using cl-letf or advice, however it might be best to avoid this since it may be used for necessary internal operations.

NOTE: you might think that having a sentinel would override internal-default-process-sentinel but it doesn't, the function always runs no matter what make-process takes for a sentinel argument.

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.