This will work if you're running as root:

1.  Compile this code into a shared object using Sun Studio C compiler (cc 
[-m64] -G plock. -o plock.so):

// source file:  plock.c
#include "sys/lock.h"
#include "stdlib.h"
#pragma init( __init_plock )
void __init_plock( void )
{
    // lock all process memory
    plock( PROCLOCK );

    // this putenv prevents the shared object from getting
    // loaded by child processes
    //
    // use "LD_PRELOAD_64=" for a 64-bit shared object
    putenv( "LD_PRELOAD_32=" );
}

2.  Place the appropriate LD_PRELOAD_32 or LD_PRELOAD_64 environment variable 
to load the shared object into memory.  Make sure it's only set for the one 
process:

LD_PRELOAD_32=/path/to/plock.so
export LD_PRELOAD_32
/start/your/locked/process/here
unset LD_PRELOAD_32
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-help mailing list
[email protected]

Reply via email to