It seems that we could use DuplicateHandle for the same process see http://support.microsoft.com/kb/150523/en-us
Bastien On Tue, May 3, 2011 at 3:00 PM, Bastien ROUCARIES <roucaries.bast...@gmail.com> wrote: > On Mon, May 2, 2011 at 3:52 PM, Paolo Bonzini <bonz...@gnu.org> wrote: >> On 05/01/2011 04:29 PM, Bastien ROUCARIES wrote: >>> >>> Did you test if dup2 work for socket ? >>> >>> According tohttp://www.suacommunity.com/dictionary/dup-entry.php >>> andhttp://blog.csdn.net/linlu11/archive/2008/06/06/2518571.aspx it >>> will need more work. >> >> dup2 indeed may not work for a socket on Windows. It would work on Wine, >> since WSADuplicateSocket is just doing DuplicateHandle on Wine, but I don't >> know what Windows actually does. >> >> That's definitely something to remember, thanks for pointing it out. >> >> Paolo >> > > How can we test without a socketpair ? > > Moreover I see another non compliance with dup2. After a dup2 of > stdin/stdout/stderr fprintf(stdout,"%s",some format) will not work > because it is using the old handle.... > > So we must use special code for fd 0,1,2 > > BTW it seems that dup fail with bad handle > http://www.winsockprogramming.info/stdio-socket > > Bastien >