Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem using $$



On May 13,  6:55pm, Rico Schiekel wrote:
}
} | ps aux | grep " $mp "
} | ps aux | grep "start.osd" | grep -v "grep" | grep -v " $mp "
} 
} |b fire      4128  0.0  0.1  2708 1324 pts/4    R+   18:33   0:00 /bin/zsh ./test.zsh
} |c fire      4172  0.0  0.1  2708 1332 pts/4    R+   18:33   0:00 /bin/zsh ./test.zsh
} 
} - first call:
}    why is the process id from the second ps [c] other than the process
}    id from the first ps [b] and $$ [a] ?

I think that's because your script is buggy.  The third call to grep in
the [c] case should not have the "-v" option.

After getting rid of the stray "-v", try using "ps alx" rather than "aux".
That will allow you to grep the $mp out of both the PID and PPID columns
and thereby see the parent/child relationship among the shells.

} |2 fire      4216  0.0  0.0     0    0 pts/4    R+   18:33   0:00 [test.zsh]
} 
} - second call:
}    and what is "[test.zsh]" [2]

The ps output has square brackets like that for a child process when the
original process has fork()ed but has not done an execv() in the child.
This means that the "ps" is running soon enough to catch zsh after it
has forked, but before it has finished starting up one of the greps that
appear later in the pipeline.  Vagaries of process scheduling.

}    and why has it got another pid (4216) than $$ (4173) [1] ?

Because your script ran 'grep -v " 4173 "'.



Messages sorted by: Reverse Date, Date, Thread, Author