<div dir="ltr">Thanks. That led me to the init_user_process_params() where it seems stdin/stdout/stderr are mapped to the running Windows program. I could not find any code that would do anything with other inherited opened fds and that led me to think that there is really no special handling and it somehow just happens to work with a winelib program (most likely because it has a bigger Linux surface to it).<div><br></div><div>Based on this, I guess what I really want to know is:</div><div><br></div><div>1 - Does a non-winelib Windows program have access to opened fds inherited during a fork/exec of Wine?</div><div>2 - If so, is there a way to actually use those fds in the Windows program?</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 20, 2019 at 7:49 PM Damjan Jovanovic <<a href="mailto:damjan.jov@gmail.com">damjan.jov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Try wine_server_fd_to_handle()</div><div><br></div><div></div><div>Once you register a fd with Wine that way, it lives inside wineserver, and during API calls, you just get back temporary copies of it, usually with different fd numbers.<br></div><div></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 21, 2019 at 1:57 AM Bruno Albuquerque <<a href="mailto:bga@gmail.com" target="_blank">bga@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is the way that wine maps file handles from Unix (Linux, more specifically) to Windows predictable?<div><br></div><div>I have this Linux program that forks Wine to run a Windows program. The Windows program can easily access stdin/stdout/stderr the way one would expect in a forked Unix program but I am trying to pass one extra file descriptor to the windows program but I am not sure how to do that.</div><div><br></div><div>In the Unix program, the FD will be, say, 3. As I am forking then exec'ing Wine, wine itself will have access to this FD and, from Wine's point of view, it should also be 3. The problem is that it seems file handles in Windows are not like in Unix (for example, stdin is not 0, stdout is not 1 and stderr is not 2) so I am assuming that to make this FD available to the WIndows program, it is somehow mapped to a file handle with a different number too. I need to know which one it si to be able to use it. Any pointers on how to do that?</div><div><br></div><div>If I compile a C program with winegcc/winelib and fork/exec it, it looks like file handles and file descriptors match so one option is to use it. But I prefer to create the program in a different language so winelib is not ideal.</div><div><br></div><div>Any help would be much appreciated.</div></div>
</blockquote></div>
</blockquote></div>