help with popen()

Jim Mercer merce at iguana.uucp
Wed Feb 6 16:32:37 AEST 1991


a snippet of code:


	char	*p_value;
	FILE	*F_pipe;
...
[	p_value points to "no_such_file"   ]

	F_pipe = popen(p_value, "r");
	if (F_pipe == NULL)
		{
		fprintf(stderr, "failure opening pipe (%s)\n", p_value);
		return(!OK);
		}
...
	pclose(F_pipe);

intention:

open a pipe to a process, use fgets to read input, warn user on pipe failure.

question:

when i run this on my 3b1, CTIX (SysV 2+ sort of),
i get "sh: no_such_file: not found" on stderr.
but, according to the if, F_pipe is not NULL.

works fine if p_value points to an existing command.

according to my documentation (Advanced Programmer's Guide to Unix System V,
McGraw-Hill), "popen() returns NULL if _command_ cannot be started".

am i doing something wrong?
is my popen() broken?

-- 
[ Jim Mercer   work: jim at lsuc.on.ca  home: merce at iguana.uucp  +1 519 570-3467 ]
[     "I am pro-military.  I am not pro-war.  There is a big difference"      ]
[                             -- Louise Mandrell (Toronto Sun)                ]



More information about the Comp.lang.c mailing list