Operating System - HP-UX
1833785 Members
2505 Online
110063 Solutions
New Discussion

Re: popen returns: errno 4 (Interrupted system call)

 
SOLVED
Go to solution
Fedele Giuseppe
Frequent Advisor

popen returns: errno 4 (Interrupted system call)

I uses a popen in a C program that randomically returns the following error:

errno = 4 - Interrupted system call

I manage the SIGCHLD signal with a proper routine that analyzes all children status by calling:
waitpid(-1, &status, WNOHANG)

Giuseppe
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: popen returns: errno 4 (Interrupted system call)

popen(3) doesn't list EAGAIN as an error return.

Having your own SIGCHLD handler may confuse pclose(3)?
Fedele Giuseppe
Frequent Advisor

Re: popen returns: errno 4 (Interrupted system call)

I made a mistake in problem detailing: the error is returned when i try to read the file opened through popen (I use fgets routine)

Dennis Handly
Acclaimed Contributor
Solution

Re: popen returns: errno 4 (Interrupted system call)

read(2) says EINTR could occur on a signal. You need to retry the read/fgets.
Fedele Giuseppe
Frequent Advisor

Re: popen returns: errno 4 (Interrupted system call)

Ok, by re-executing the fgets in case of EINTR error, it works.

Many thanks