[Ace-users] [ace-users] Pipes on Win32 and Unix
Douglas C. Schmidt
schmidt at dre.vanderbilt.edu
Thu Jan 31 17:25:20 CST 2008
Hi,
Please take a look at
ACE_ROOT/tests/Pipe_Test.cpp
ACE_ROOT/examples/OS/Process
for some examples of using ACE_Pipe that are similar to what you're
trying to do below.
Thanks,
Doug
>Could anyone advise me how to make this code to run exactly the same
>on both Win32 and Unix ?
>
>==========
>Main program:
>
>int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
>{
> ACE_Process nmproc;
> ACE_Process_Options nm_opts;
> nm_opts.command_line("testEcho");
>
> ACE_HANDLE pipe[2];
> ACE_OS::pipe(pipe);
> nm_opts.set_handles(pipe[0]);
> ACE_OS::close(pipe[0]);
> nmproc.spawn(nm_opts);
> ACE_OS::write(pipe[1], "aa\n", 2);
> nm_opts.release_handles();
> ACE_OS::close(pipe[1]);
> return 0;
>}
>
>==========
>testEcho program:
>
>int main(int argc, char* argv[])
>{
> printf("TestEcho started\n");
> char buf[100];
> scanf("%s", buf);
> fprintf(stdout, "StdOut:%s\n", buf);
> fprintf(stderr, "StdErr:%s\n", buf);
>
> return 0;
>}
>
>
>==========
>On Win32 I got the following:
> after a call to "ACE_OS::close(pipe[1]);", the testEcho is closed
>immidiately and the output is :
>TestEcho started
>StdOut:aa
>StdErr:aa
>
>But when I run this code on Linux, testEcho is never terminated, and
>the output is only:
>TestEcho started
>
>Please help.
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.schmidt at vanderbilt.edu
More information about the Ace-users
mailing list