-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 06/20/2014 06:41 PM, Arjun RP wrote: > Hi all, How to write a program in which the main program spawns an > executable, the main program need to pass data to the stdin of > newly created process, then the new process will write something > back to stdout. The stdout and stdin of new process can be > manipulated using our parent process, but in all the tutorials and > examples(https://github.com/joyent/libuv/blob/master/test/test-stdio-over-pipes.c#L141 > > ) are written in such a way that at first the parent will read something > from the child, then the parent write to the client. How can we > write code where the parent needs to write first and read last > > For a sample test, let our executable be an echo client like: > #include<stdio.h> int main(){ char a[1024]="\0"; scanf("%s",a); > //read something from stdin printf("%s",a); // echo the data read > from stdin to stdout return 0; } >
Hi, After you spawned the new process with 2 pipes for stdio, you can just uv_write to the pipe representing the child process' stdin, there is no ordering requirement for read/write operations. Cheers, - -- Saúl Ibarra Corretgé bettercallsaghul.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBAgAGBQJTpJ1vAAoJEEEOVVOum8BZWpIP+QGInXf9tV4e0M0rz5yBiMtn pXs4UvFK41GXGMhP4Q1QS5DwaYJ6nNZJfF5PooY0yrFN0Bl+rA/oCqKO/PyL0eKv A46UBLvesS49GOyL1We4d9FGV4gGwxdD0H9lmZWIQMRoQRcXz+t9MQJ8nCqg2VWD tiX4yQFT//Ru38Jrag2JO3C+FvqsNayqXyMMgH7MFpquF3lhkTW1HGyJdDL1ycGQ ZfF0eGDeB5m3IPmJweVnSwsU9jcAJ2HX1bjeO8t2qCII1P4s79G8/MX/uZt4zHfv eHs5VFkZebh18E6VTQMxvPyYprBLesn0FSUaFbCgo88RoytucHjAVEce1zMVj+ei QqDs0h7ZiqQcUMC1qls5Ju4ipHnEWJleAv6BVemgWhpSPUNCvFwyCvABmDOZk2zn smN++Nx1ygp4ZX4T5tjNnjjlqRIou+0oSFUdkICOjs7Z3EIm0LDJvGIXGt1YGTNE IfddTud4JgYp+AjimSjm/e0rx92XtnKEb8f9HUoiotsT7aAiM9x4uSPeLJsDkdUP AH0dS2RGsKAxdcY++gDGFWIyUe/gQ8O6qTF27jJm8pmDA+wGElT0jk2wBzBUooNS c2GTs09ttJs2pTkMi0pi1W5JIyRzwuUoAb0+o1hNIXR0b4+ZK/LM7Yu2DzesbSZ3 ycU6x+EC4rrv9jj5Q/FR =yjU8 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
