Skip to content
Prev 32679 / 398526 Next

How to check if a pipe was successfully opened or not?

On Fri, 30 May 2003, Henrik Bengtsson wrote:

            
open() always returns NULL.
The C code called by open() has

    fp = popen(con->description, mode);
    if(!fp) {
	warning("cannot open cmd `%s'", con->description);
	return FALSE;
    }

so presumably your system's popen is returning a FILE stream even though 
the command cannot be opened.  Not much we can do about that.  Solaris 
says

    The popen() function returns a null pointer if files or
    processes cannot be created.

but I think the problem is that the `process' is that launching the shell, 
not that of the command.  I am not using Windows, so cannot check there.