Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid fork(3) - prefer vfork(2) #54

Closed
x42 opened this issue Jul 24, 2019 · 8 comments
Closed

Avoid fork(3) - prefer vfork(2) #54

x42 opened this issue Jul 24, 2019 · 8 comments
Assignees
Labels
feature request Feature request
Milestone

Comments

@x42
Copy link

x42 commented Jul 24, 2019

The problem with fork() is that it duplicates the page tables and file-descriptors of the parent process. It is inherently not realtime-safe. Any processes that has realtime threads (here a plugin-host) should not use fork(). In context of pro-audio on POSIX systems, prefer vfork(); execve();

https://github.com/sadko4u/lsp-plugins/blob/543e17e9de3b8dc9de6e31438d1223d792054626/src/ui/tk/widgets/LSPHyperlink.cpp#L107

PS. You may also investigate using posix_spawn(), but that's a library function on Linux.

@sadko4u sadko4u self-assigned this Jul 24, 2019
@sadko4u sadko4u added this to the 1.1.11 milestone Jul 24, 2019
@sadko4u sadko4u added the feature request Feature request label Jul 24, 2019
@sadko4u
Copy link
Collaborator

sadko4u commented Aug 14, 2019

The things should go right after this commit: 03174d7

@x42 please verify.

@x42
Copy link
Author

x42 commented Aug 14, 2019

Fine IFF __USE_GNU is defined at compile time. Can that happen?

If so, you could use a wrapper application that does the file re-direct after vfork+exec.

@sadko4u
Copy link
Collaborator

sadko4u commented Aug 15, 2019

@x42 right
Changed code to use vfork() directly when __USE_GNU is not defined.
Here's the following commit: 88a8ede

@x42
Copy link
Author

x42 commented Aug 15, 2019

Looks good. Thanks!

Could that happen in the first place though? On what POSIX OS + compiler is __USE_GNU not defined? Can that even happen?

@sadko4u
Copy link
Collaborator

sadko4u commented Aug 15, 2019

@x42 __USE_GNU is not defined on FreeBSD 11. There, <spawn.h> does not provide a flag that tells posix_spawn to prefer vfork().

@sadko4u
Copy link
Collaborator

sadko4u commented Aug 15, 2019

Merged changes into devel branch: 4bef72f

@sadko4u
Copy link
Collaborator

sadko4u commented Aug 28, 2019

Removed github-issue-54 branch

@sadko4u sadko4u removed the PENDING FOR RELEASE This issue will be added to the nearest upcoming release label Dec 21, 2019
@sadko4u
Copy link
Collaborator

sadko4u commented Dec 21, 2019

Available in the 1.1.11 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants