[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tue, 5 Feb 2002 11:58:40 -0800 (PST)
> From: Akim Demaille <address@hidden>
> Date: 05 Feb 2002 13:10:55 +0100
> Paul, is tried to avoid popen/pclose for performance issues, when
> running m4. Would you say, that's a pointless optimization and just
> use popen,
No, it's not pointless. It's more than just a performance issue:
popen has its own set of porting problems (e.g. with respect to signal
handling), and they are best avoided if possible.
> or, should readpipe fallback to popen/pclose when
> pipe/fork are not supported?
Yes, that sounds reasonable. That's how diffutils does it (it doesn't
use readpipe). However, it's a bit tricky to do:
* You have to quote the shell arguments correctly. Diffutils uses
quote_system_arg for that.
* You have to deal with pclose returning -1, as opposed to some
other nonzero value.
* You have to deal with exit status 126 (not executable) and 127 (not
found). Hmm, I see now that Diffutils doesn't do that right -- I'll
have to fix it....
readpipe isn't enough to do what Diffutils needs, e.g. it doesn't take
an arg vector. I guess it could be generalized though.