[torquedev] fork_to_user

David Singleton David.Singleton at anu.edu.au
Mon Apr 14 03:15:54 MDT 2008


In trying to cleanup fork_to_user() in our version of OpenPBS, I
noticed some dodginess in the use of the error return codes.  In
checking what Torque does, it appears that it is dodgy in a different
(but essentially the same) way.  The issue is possibly not serious
but can lead to MOM exiting or a MOM child persisting and "playing
MOM".

Below is a summary of the return codes from fork_to_user() to
req_cpyfile(). I haven't checked the other use of fork_to_user().

return ##  can lead to MOM exiting if she has trouble with a user
            home dir

return ### can lead to a child "playing MOM" if a malloc or setuid
            fails (unlikely, I know)

More than happy for someone to point out my misunderstanding - then
I may not have to fix anything :-).

David


req_cpyfile( )
{
       rc = fork_to_user(preq);

        -----> fork_to_user(preq)
               {
                    /* As main MOM we see various  */
                         return(-PBSE_BADUSER);
                    /* and */
                         return(-PBSE_UNKRESC);  /* ## */

                    pid = fork_me(preq->rq_conn);

                    if (pid < 0)  return(-PBSE_SYSTEM);

                    if (pid > 0)  return pid;

                    /* Now as child we see various */
                         return(-PBSE_BADUSER); /* ### */
                    /* and */
                         return(-PBSE_UNKRESC);

                    return(pid); /* pid is 0 ??? */
                }
         <-------

         if (rc < 0) { /* FAILURE */

                 req_reject(-rc, preq);

                 if ((rc != -PBSE_SYSTEM) && (rc != -PBSE_BADUSER)) {
                     exit(rc);
                 }

                 return;
         }

         if (rc > 0) return;  /* parent */

         /* child - do stuff */

          ...
}



More information about the torquedev mailing list