[torqueusers] changing session id.
David Groep
davidg at nikhef.nl
Wed Feb 23 10:33:25 MST 2005
Garrick Staples wrote:
> This is the big mystery. If you find a solution to this problem, we'd all love
> to hear about it!
Not a real solution but a hack around it:
* every job that ligitimate runs on a node is within the
process group of the initial job script started by pbs_mom
* daemonized processes (that's what the code below does) are not
in any of the process trees in any PBS jobs known on that node
* the processID of the initial job script is contained in the
.TK file in $PBSHOME/mom_priv/jobs/
So:
* look for all processes by a user in the epilogue
* subtract all ligitimate processes from that user (from other jobs
on the same node except for your own's)
* kill the remainer.
The following code snipper works on Torque-1.1.x, but you can easily
find the appropriate place in other .TK files. it lists all valid
(of course non-daemonized) processes in the process group
corresponding to pbs job $jobid.
But a proper client interface/API/script to get this initial process number
would be great to have!
#! /bin/sh
#
case "$#" in
1 ) jobid=`echo $1 | sed -e 's/\..*//'` ;;
* ) echo "Usage: $0 pbs_jobid" >&2 ; exit 1 ;;
esac
pid=`od --width=2 -j 96 -N 2 -i /var/spool/pbs/mom_priv/jobs/$jobid.*.TK/* | awk '{ print $2 }'`
ps -fg $pid
Cheers,
DavidG.
>
> On Thu, Feb 17, 2005 at 09:08:44AM +0000, Steve Traylen alleged:
>
>>Hi,
>>
>> I am looking for some suggestions on how to deal with the problem
>> of users changing their session or group id and thus enabling
>> themselves to leave process on batch workers. The code below highlights
>> a way to do this.
>>
>> Has anyone else considered this and have they implemented anything
>> to address the situation. Either to stop it in the first place or
>> to clean it up afterwards. For the clean up it is less than trivial
>> since we run two jobs per node so simply cleaning all process belonging
>> to a user in the epilogue is not an option.
>>
>> Steve
>>
>>
>>#include <sys/types.h>
>>#include <unistd.h>
>>
>>int main(int argc, char **argv) {
>> pid_t p = fork();
>> if (p == (pid_t) -1) {
>> exit(0); /* we failed.... */
>> } else if (p == 0) { /* CHILD */
>> setsid(); /* new session */
>> setpgid(0, 0);
>> } else { /* PARENT */
>> exit(0);
>> }
>>
>> /* Do something usefull here */
>> sleep(6000);
>>}
>>
>>
>>
>>--
>>Steve Traylen
>>s.traylen at rl.ac.uk
>>http://www.gridpp.ac.uk/
>>_______________________________________________
>>torqueusers mailing list
>>torqueusers at supercluster.org
>>http://supercluster.org/mailman/listinfo/torqueusers
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> torqueusers mailing list
> torqueusers at supercluster.org
> http://supercluster.org/mailman/listinfo/torqueusers
--
David Groep
** National Institute for Nuclear and High Energy Physics, PDP/Grid group **
** Room: H1.56 Phone: +31 20 5922179, PObox 41882, NL-1009DB Amsterdam NL **
More information about the torqueusers
mailing list