Why Does Fork Fail in Linux?
Primary Software: Driver Software>>NI-488.2
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: Driver Software>>NI-DAQmx Base
I am using a fork() call in my code that's running in Linux, and the fork() fails. What is going on?
This may happen in Linux kernels 2.6.13 and newer, due to the way the NI driver handles page-locked user mode memory. In kernels 2.6.13 and later, the driver calls mlock() to lock user mode memory. If there is not enough lockable memory available, mlock() can fail, causing fork() to fail.
Try running the process as root user, and see if fork() succeeds. If fork() succeeds, it's possible that fork() failed because mlock() failed.
As a non-root user, run "ulimit -a" to determine the amount of maximum locked memory. This value can be increased by editing /etc/security/limits.conf. See your Linux distribution documents for more information about how to do this.
Report Date: 06/20/2007
Last Updated: 09/29/2017
Document ID: 4AJE5KQA