[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 'tty' output on kFreeBSD, etc. within sbuild

On Fri, Jan 03, 2014 at 06:51:08PM +0000, Alastair McKinstry wrote:
> Can anyone answer the following question which is puzzling me;
> I have a piece of csh code which gets called during the build of a package
> i'm maintaining. it does the following:
> echo "useful information" > /dev/tty
> within the script. (stdout, stderr being redirected, I think).
> This fails on kFreeBSD at least, so i've patched it to:
> set ttyf=`tty`
> ...
> echo "useful information" > $ttyf
> This works on Linux, and on the command line for me on a kFreeBSD machine,
> but under sbuild I get:
> $ttyf: Ambiguous.
> Unable to build Makefile - fix above errors and re-run.
> Any ideas as to whats happening and what I should do about it?

You aren't guaranteed to have a controlling terminal, particularly when
run via buildd.  So while stdin/out/err are all connected and
functional, they are either null (stdin) or pipes (out/err).  If you
need to output anything, then just use stdout/err as appropriate and it
will be logged, but /dev/tty may well be unavailable.  I would
recommend not using `tty` or doing any IO on /dev/tty since in all
likelihood isatty/ttyname(_r) will most likely return ENOTTY and any
IO on /dev/tty will simply fail.

We have looked at using ptys in the past for running the builds in
order to guarantee a tty, but decided against it.  Too many programs
make the assumption that they are interactive and freeze the build
waiting on IO that never happens and then block forever.  There may
well have been other considerations I don't recall offhand e.g.
relating to job control.


  .''`.  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.

Attachment: signature.asc
Description: Digital signature

Reply to: