[buildd-tools-devel] Bug#679499: Bug#679499: schroot: suspend fails from chroot

Roger Leigh rleigh at codelibre.net
Sun Oct 14 23:16:16 UTC 2012


On Fri, Jun 29, 2012 at 09:00:31AM +0100, Toby Speight wrote:
> If I use plain 'chroot' to access a working system, with
> SHELL=/bin/bash, I can type 'suspend' into bash, and get back to my
> parent shell.
> 
> If I use 'schroot' to do the same, then 'suspend' just hangs until I
> go to another terminal and 'kill -CONT' the bash process.
> 
> I would like schroot to behave the same as plain chroot.  I appreciate
> it might not be trivial (chroot doesn't have to do anything special, as
> it simply exec()s the required command, whereas schroot would have to
> detect its child stopping and do the same to itself - I've no idea how
> to do that).

This is quite an interesting problem, and will need a bit more
investigation before I find a solution.

bash sets up its own process group on startup.  When you call
"suspend", it signals the whole process group to stop.  But since
schroot isn't in the same group, it's not suspended.  Ideally,
you would only run a login shell with schroot, but we're not in
an ideal world ;)

schroot uses PAM, and basically treats commands being run in the
chroot as though they were run as a separate login, e.g. equivalent
to running ssh or sudo.  That said, it should be possible to do this.

schroot itself isn't doing anything special by starting any new
sessions with setsid or setpgid, and itself works perfectly well
with job control.  Try running any command other than a shell
(e.g. "more" or anything you like, or run schroot as part of a
pipeline e.g. "schroot ls -l / | less") and you'll see that it
all works fine in that you can press C-Z and it all suspends
properly.

So to support suspending a shell within ourselves, I'm not sure what
is best to do here.  I'll try trapping SIGCONT/SIGSTOP, and then
raise the same signal on ourselves.  However, this could open a
horrible can of worms, e.g. if you send SIGCONT to bash while
schroot is stopped.  We won't be restarted ourselves then, and
bash might then immediately get SIGTTOU/IN etc.  I also don't want
to break schroot running correctly in the normal/pipeline cases
shown above.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.



More information about the Buildd-tools-devel mailing list