Linux shared library that calls fork as Winelib DLL

Questions about Wine on Linux
Locked
abcdefg
Level 1
Level 1
Posts: 9
Joined: Mon Aug 02, 2021 10:12 am

Linux shared library that calls fork as Winelib DLL

Post by abcdefg »

Quite simply, I want to take advantage of Winelib's ability to use a Linux shared library as if it were a Windows DLL. However, the Linux shared library in question calls fork. The library relies on the parent process remaining in the Linux shared library code while the child returns to the main application running under Wine and continues execution of the Windows code.

This breaks the code in both the Linux shared library and the Windows main application running under Wine. The parent process in the Linux shared library stops executing any instructions after the fork, and the child process returns to the application with undefined behavior (most of the time terminates on a simple example program, sometimes stops execution part-way through, etc).

Does anyone have ideas for how I can make this library work? I have source for both the Linux library and the main Windows application, so I can make any modifications I want to either. Also, if there is some patch to the Wine source that could be made to enable the use of fork-dependent Linux shared libraries as Winelib's, I am happy to work on that patch.

Note: This is a clarified version of a post I made previously that better describes what I want to do.

Thank you.
madewokherd
Level 4
Level 4
Posts: 149
Joined: Mon Jun 02, 2008 5:03 pm

Re: Linux shared library that calls fork as Winelib DLL

Post by madewokherd »

Is there a reason it has to be the child process that continues executing Windows code? The wineserver knows the Linux pid of each Windows process and would be unable to send signals to that process or otherwise manipulate it. Also, the process of forking will terminate all other threads in the child process, and there are certain things you're just not supposed to do after a fork on the child side. I'm not sure exactly what will break, but I don't imagine it would go well.

I'd expect it to work better if the child process continues with Linux code and the parent process returns to Windows code. You would still be limited by the restrictions on what you can do between a fork and exec, but at least it has some chance of working.
abcdefg
Level 1
Level 1
Posts: 9
Joined: Mon Aug 02, 2021 10:12 am

Re: Linux shared library that calls fork as Winelib DLL

Post by abcdefg »

Thank you for the response! I need the child to return and parent to remain in the library so that the parent can do things like wait on the child, receive signals etc.
Locked