Re: tty or script(1) weirdness?

2010-03-11 Thread Gary Jennejohn
On Wed, 10 Mar 2010 21:04:10 +0100
Ed Schouten  wrote:

> * Ed Schouten  wrote:
> > Hmmm... It seems this is a TTY bug. When you close a TTY, the final
> > close() call should get stuck until all data is actually drained. This
> > doesn't seem to happen properly.
> 
> Some further research: it's not a TTY bug, but a bug in script(1).
> The script parent process leaves a file descriptor open, which means
> output is never properly drained.
> 
> I can't reproduce this issue after applying this patch:
> 
> %%%
> Index: script.c
> ===
> --- script.c  (revision 204965)
> +++ script.c  (working copy)
> @@ -158,6 +158,8 @@
>   }
>   if (child == 0)
>   doshell(argv);
> + else
> + close(slave);
>  
>   if (flushtime > 0)
>   tvp = &tv;
> %%%
> 

Looks very convincing.  I say commit it.

---
Gary Jennejohn
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: tty or script(1) weirdness?

2010-03-10 Thread Ed Schouten
* Ed Schouten  wrote:
> Hmmm... It seems this is a TTY bug. When you close a TTY, the final
> close() call should get stuck until all data is actually drained. This
> doesn't seem to happen properly.

Some further research: it's not a TTY bug, but a bug in script(1).
The script parent process leaves a file descriptor open, which means
output is never properly drained.

I can't reproduce this issue after applying this patch:

%%%
Index: script.c
===
--- script.c(revision 204965)
+++ script.c(working copy)
@@ -158,6 +158,8 @@
}
if (child == 0)
doshell(argv);
+   else
+   close(slave);
 
if (flushtime > 0)
tvp = &tv;
%%%

-- 
 Ed Schouten 
 WWW: http://80386.nl/


pgpo052DoqSPZ.pgp
Description: PGP signature


Re: tty or script(1) weirdness?

2010-03-10 Thread Ed Schouten
Hi Alfred,

* Alfred Perlstein  wrote:
>  1) download the suite.
>  2) run "sh test.sh" to see the bug
>  3) run "sh test.sh yes" to not see the bug (sleep called)

Hmmm... It seems this is a TTY bug. When you close a TTY, the final
close() call should get stuck until all data is actually drained. This
doesn't seem to happen properly.

You can easily test this by performing a tcdrain() right after running
your perl script:

#include 

| int
| main(int argc, char *argv[])
| {
| 
|   tcdrain(0);
| }

I'll see what I can do.

-- 
 Ed Schouten 
 WWW: http://80386.nl/


pgpDNzomltaDM.pgp
Description: PGP signature


tty or script(1) weirdness?

2010-03-10 Thread Alfred Perlstein
Hey Ed, Hackers

I've been experiencing a weird issue where when I invoke a program
via script and it exits after much output, it seems to have its
output truncated.

The data winds up not on the screen or in the log file.

I have a link here to a set of scripts that will easily
provoke this issue.

The shell script "test.sh" calls the perl script under "script"
then makes sure that the expected number of characters are emitted.

If you run "test.sh" with an argument, it will have the perl script
"sleep(1)", then you will not see the problem.

As a stop-gap, I'm probably going to add the sleep(1) to my code at
work, but I'm worried that:

1) I'm dumb and am doing something really silly and ought to be mocked
for it. :)
2) Something is broken in the tty system?
3) Script has more bugs than I had originally thoughts.

Anyhow, to test this:
 1) download the suite.
 2) run "sh test.sh" to see the bug
 3) run "sh test.sh yes" to not see the bug (sleep called)

Here's a link to the scripts:
http://www.mu.org/~bright/scripttest/

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"