tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: $$ broken??

> On Mon, Mar 25, 2013 at 01:22:05AM -0400, Mouse wrote:
>> I have a weird situation which looks as though $$ is broken in sh.
> ...
>> The real question I have here is, why is $$ in rc.local giving me the
>> wrong value?

All rc scripts (except those ending in .sh) are sourced in a
subshell. Subshells' $$ is the same as their parents'.

>> Perhaps more importantly, what can I do to fix it?  Failing that, is
>> there some other tool I can use to give me the correct PID as a
>> workaround?

It's a bit ugly and requires /proc being mounted, but this should work:

cd /proc/curproc && { thispid=${PWD##*/}; cd $OLDPWD; }

Or, ugly in another way:

thispid=$(ksh -c 'echo $PPID')

On Mon, Mar 25, 2013 at 10:04 AM, David Laight <> 
> Maybe: syctl proc.curproc.rlimit....

It will change the limits of the sysctl process...

kind regards

Home | Main Index | Thread Index | Old Index