Hi

I have the following scenarios: client/server programs implemented with winsock are installed on all systems inthe network (assume it contains s1, s2, and s3, and other systems). If I send a command from s0 client to s1 server, which ask s1 server to execute a command line of s1 client to talk with s2 server, s2 server will return value (error code in my case) to s1 client. My question is how I can get the returned value on s0

The command line execution on s1 is realized by calling system(), to which I pass the client program name (the client program will returns error code), and the processed data from s0, but system() only return -1 or 0 to indicate error or succeed. I also looked at CreateProcess(), but still couldn't see how I can get the returned value from client execution

S0: Client/Serve
/


\
S1:Server/Clinet <------------------------------>Server/Client:S

Anybody got idea

Thanks
Peter

Re: How to get returned value from a spawned process? by Igor

Igor
Tue Mar 02 20:16:25 CST 2004

"Peter" <anonymous@discussions.microsoft.com> wrote in message
news:E83F4BD3-6C4E-4F43-8D13-BDD68EFF2488@microsoft.com...
> The command line execution on s1 is realized by calling system(), to
which I pass the client program name (the client program will returns
error code), and the processed data from s0, but system() only return -1
or 0 to indicate error or succeed.

According to documentation, system() is supposed to return whatever the
command processor returned, which in its turn should return the exit
code of the application. BTW, -1 is a legal success value - you should
distinguish between success and failure by setting errno to 0 before the
call, and checking it after the call.

I haven't used system() myself though.

> I also looked at CreateProcess(), but still couldn't see how I can get
the returned value from client execution.

GetExitCodeProcess
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken