On Fri, Mar 02, 2007 at 11:25:11AM +0100, Mechiel Lukkien wrote: > Hi all, > > It seems mlock does not work on OpenBSD/i386 for non-root users. On other > archs it might work as non-root (looking at the code), but I don't have > a machine to test. It seems this has existed for a long time: > > http://marc.theaimsgroup.com/?l=openbsd-misc&m=93761396111587&w=2 > > Mlock fails and sets EPERM, which is not specified in the manual page. > It should probably be listed. > > I tested with this program, perhaps I am using mlock incorrectly ("it > works on another OS" probably isn't a good argument ;-)): > > http://www.xs4all.nl/~mechiel/tmp/memlock.c > > There seems to be a system-wide limit to prevent abuse by random users, > so that probably isn't the reason to not allow mlock... Does anyone > know why mlock should not work? > > Regards, > Mechiel > >
>From http://www.opengroup.org/onlinepubs/009695399/functions/mlock.html "The appropriate privilege is required to lock process memory with mlock()" So getting an EPERM is the norm if your're a normal user on most OS. You didn't ask for it, but let me guess. You want to protect some super secret data from being swaped out to disk. OpenBSD does have encrypted swap enabled by default. Tobias