Brian Dessent wrote:
system() is just a wrapper around spawnvp(). If spawn() isn't what you
want then neither is system(). spawn() does not necessarily replace the
current process (_P_OVERLAY), it can also start and optionally wait for
a subprocess (_P_WAIT, _P_NOWAIT, _P_DETACH).
Excellent
Hi all,
I've been through the FAQ and 2 years worth of archives, trying every
trick I could find there, but I cannot make this work. I have a program
which calls Cygwin's system() function. It works reliably from the
Windows command line (outside of Cygwin) on machines that have Cygwin
Archie Warnock wrote:
[snip]
It seems obvious to me that system() is not finding a command
interpreter on the machine,
Exactly!
although they are correctly listed in the
path for the command window. Am I missing something really stupid that
needs to be included in the distribution or set
René Berber wrote:
Yes, you are missing something really simple... have you seen the man
page for system()? Of course not, Use `system' to pass a command
string `*S' to `/bin/sh'...
Hmmm... you're right. Thanks. I was hoping the mention of /bin/sh was
more figurative - ie, just _a_
Archie Warnock wrote:
[snip]
So, what would be the right way to call an external program from a
Cygwin program without installing Cygwin, if not system()?
I don't know if it works but I would try to use popen(), there's also exec() and
all it's relatives.
I also find it somewhat puzzling
Archie Warnock wrote:
Hmmm... you're right. Thanks. I was hoping the mention of /bin/sh was
more figurative - ie, just _a_ command interpreter. Guess not, eh?
That is how system() works on every unix platform: /bin/sh -c %s
So, what would be the right way to call an external program from
René Berber wrote:
I don't know if it works but I would try to use popen(), there's also
exec() and all it's relatives.
I'll try popen. I'm not inclined to use anything from exec or spawn - I
don't want to replace the program. I just need to run an external
program and read the results back
Brian Dessent wrote:
That is how system() works on every unix platform: /bin/sh -c %s
Yep. Got it.
You could fork() and exec(), or just call one of the spawn() family of
functions. This is all open source you know, you could look and see how
system() is implemented in
Archie Warnock wrote:
The path is irrelevent because it's called as /bin/sh -c cmd, and the
location of /bin is taken from the mount table. On your systems without
Ummm... are you saying that I have a Cygwin mount table outside of Cygwin?
Ahh... I see it now. Thanks for the pointer.
--
Archie Warnock wrote:
You could fork() and exec(), or just call one of the spawn() family of
functions. This is all open source you know, you could look and see how
system() is implemented in winsup/cygwin/syscalls.cc.
I'll have to look and see there. The fork()/exec()/spawn()
10 matches
Mail list logo