| Jeff Abrahamson on Mon, 26 Aug 2002 22:40:18 +0200 |
|
On Mon, Aug 26, 2002 at 04:16:38PM +0200, Jeff Abrahamson wrote:
> I've been hitting my head on the wall for several hours now. I wrote a
> simple program, mostly cribbed from Stevens (APUE), to let me run a
> process and talk to it.
>
> As my example, I just use dc. I want to type "1 2 +p" to it and see it
> say "3". I know I could have buffering issues, but that would be an
> improvement. Eventually, it'll be my own program I talk to and I can
> turn off buffering.
>
> As it happens, dc just sits there defunct before I first write to it,
> so when I do write I get a SIGPIPE. I can see this by breaking in gdb
> at the fgets(...stdin) at line 74. So I'm guessing dc's stdin is
> closed.
>
> I've attached the sample program, it may be compiled with
>
> gcc -g -O2 -Wall -W test-fork.c -o test-fork
>
> Anyone see what I'm doing wrong?
>
> Thanks much in advance for any tips.
Found it. Going out for hot chocolate is a good debugging
technique. As is printf, of course.
I had picked some of the driving code from the rsync source. In
do_cmd, the following line causes many a problem if you're not rsync
running as a daemon:
args[argc++] = ".";
Removing that line solved the problem.
--
Jeff
Jeff Abrahamson <http://www.purple.com/jeff/>
Attachment:
pgptndzEFW6OC.pgp
|
|