[Bug 757244] Re: Jobs won't start using pdsh if script fd >= 10

Yuri Zaporozhets 757244 at bugs.launchpad.net
Tue Jun 7 22:23:37 CEST 2011


Actually, the fix commited in 1280 does not work in all cases. Namely,
when init has 7 (seven) files open. In this case the communication
channel has the fd=8, and the first pipe call in job_process_run()
returns (9, 10). This means that the script_fd parameter passed to
job_process_spawn() also equals to 9. In such case the following code is
screwed up completely

if (script_fd != -1) {
  int tmp = dup2(script_fd, JOB_PROCESS_SCRIPT_FD); /* dup2(9, 9) returns 9 */
  /*...*/
  close(script_fd); /* Close our current file descriptor */
  script_fd = tmp; /* ...which means a big trouble */
}

The correct way is, of course, not only to check script_fd against -1,
but also check if it's already 9:

if ((script_fd != -1) && (script_fd != JOB_PROCESS_SCRIPT_FD)) {
  /*...*/
}


** Changed in: upstart
       Status: Fix Committed => Incomplete

-- 
You received this bug notification because you are subscribed to PLD
Linux.
https://bugs.launchpad.net/bugs/757244

Title:
  Jobs won't start using pdsh if script fd >= 10

Status in Upstart:
  Incomplete
Status in PLD Linux Distribution:
  New

Bug description:
  After upgrading Upstart to 1.2 I found some of my jobs not starting
  (exiting with code '127'). After some investigation I found out that
  Upstart prepends 'exec 10<&-' to the scripts of the failing jobs, to
  close the input pipe. The problem is this won't work for some POSIX
  shells, which can handle only single-digit file descriptors this way.
  This works for the big and heavy bash, but won't for under PDKSH (used
  as /bin/sh in e.g. PLD Linux).

  Can upstart be made to use some fixed file descriptor for this task?
  e.g. '3'?


More information about the pld-bugs mailing list