Skip to content
Advertisement

output from popen doesn’t capture the error return

I was trying to capture the output from popen.

The command that I am using is

JavaScript

If you execute the above command in shell, you will get a message Terminated. My objective is to get the message Terminated in a buffer. I used the code below, but it didn’t work.

JavaScript

Any ideas why it is not working ? Or if there is a better way to do it in C, that will be helpful as well.

Advertisement

Answer

The message is printed by the shell, and only when it’s run in interactive mode. So you need to run a shell process with -i to get the message.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement