[net.bugs.4bsd] error

zemon@felix.UUCP (05/25/84)

Index:	ucb/error/errormain.c	4.2BSD	    Fix
----------

Description:
    Error(1) will not work if it is run when not attached to a
    terminal.  For example, error(1) will fail when run under
    control of at(1) or the MDQS batch(1) command.

    The reason is that error(1) always attempts to open
    /dev/tty.  Error(1) exits if the open fails.  It is only
    necessary to open /dev/tty if the -q option is given.

    This applies to error(1) as distributed with 4.2bsd.  It
    probably also applies to earlier versions.  The sccsid line
    from out version of error(1) is:
	*sccsid = "@(#)errormain.c	1.4 (Berkeley) 5/4/82";

Repeat-By:
    Execute something like this within an MDQS batch queue using
    the C shell:
	( cc ... |& error > error-stdout ) >& error-stderr

    "error-stdout" should contain standard status information
    from error(1) and "error-stderr" should be empty.  Instead,
    "error-stdout" will be empty and "error-stderr" will contain
    the message "error: Can't open /dev/tty to query the user.".

Fix:
    RCS file: RCS/errormain.c,v
    retrieving revision 1.1
    diff  -r1.1 errormain.c
    0a1,11
    > /*
    >  * $Log:	errormain.c,v $
    >  * Revision 1.2  84/05/24  15:55:16  zemon
    >  * Don't open /dev/tty unless -q is specified.
    >  * This is necessary to allow running error under MDQS batch.
    >  * If the change is not installed, the attempted open of /dev/tty
    >  * fails when the MDQS daemon is not attached to a terminal.
    >  * 
    >  */
    > 
    > #ifndef lint
    1a13,15
    > static	char rcsid[] = "$Header: errormain.c,v 1.2 84/05/24 15:55:16 zemon Exp $";
    > #endif
    > 
    127,131c141,148
    < 	im_on = "/dev/tty";
    < 	if ( (queryfile = fopen(im_on, "r")) == NULL){
    < 		fprintf(stderr,"%s: Can't open \"%s\" to query the user.\n",
    < 			processname, im_on);
    < 		exit(9);
    ---
    > 	if (query) {
    > 		im_on = "/dev/tty";
    > 		if ( (queryfile = fopen(im_on, "r")) == NULL){
    > 			fprintf(stderr,
    > 				"%s: Can't open \"%s\" to query the user.\n",
    > 				processname, im_on);
    > 			exit(9);
    > 		}
    132a150
    > 	

Submitted-by:
    Art Zemon
    FileNet Corp.
    ...!{ucbvax,decvax}!trwrb!felix!zemon
    (714)966-2344

zemon@felix.UUCP (05/25/84)

Index:	ucb/error/errormain.c	4.2BSD	    Fix

Description:
    Error(1) will not work if it is run when not attached to a
    terminal.  For example, error(1) will fail when run under
    control of at(1) or the MDQS batch(1) command.

    The reason is that error(1) always attempts to open
    /dev/tty.  Error(1) exits if the open fails.  It is only
    necessary to open /dev/tty if the -q option is given.

    This applies to error(1) as distributed with 4.2bsd.  It
    probably also applies to earlier versions.  The sccsid line
    from out version of error(1) is:
	*sccsid = "@(#)errormain.c	1.4 (Berkeley) 5/4/82";

Repeat-By:
    Execute something like this within an MDQS batch queue using
    the C shell:
	( cc ... |& error > error-stdout ) >& error-stderr

    "error-stdout" should contain standard status information
    from error(1) and "error-stderr" should be empty.  Instead,
    "error-stdout" will be empty and "error-stderr" will contain
    the message "error: Can't open /dev/tty to query the user.".

Fix:
RCS file: RCS/errormain.c,v
retrieving revision 1.1
diff  -r1.1 errormain.c
17c39
< char	*im_on;			/* my tty name */
---
> char	im_on[] =	    "/dev/tty";			/* my tty name */
127,131c149,155
< 	im_on = "/dev/tty";
< 	if ( (queryfile = fopen(im_on, "r")) == NULL){
< 		fprintf(stderr,"%s: Can't open \"%s\" to query the user.\n",
< 			processname, im_on);
< 		exit(9);
---
> 	if (query) {
> 		if ( (queryfile = fopen(im_on, "r")) == NULL){
> 			fprintf(stderr,
> 				"%s: Can't open \"%s\" to query the user.\n",
> 				processname, im_on);
> 			exit(9);
> 		}
132a157
> 	


Submitted-by:
    Art Zemon
    FileNet Corp.
    ...!{ucbvax,decvax}!trwrb!felix!zemon
    (714)966-2344