util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix "Script started" buffering race
@ 2015-02-06 18:59 Stanislav Brabec
  2015-02-10 10:28 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Stanislav Brabec @ 2015-02-06 18:59 UTC (permalink / raw)
  To: Util-Linux

script -c "echo Hallo World" </dev/null >script.log ; cat script.log

Before:
Hallo World
Script started, file is typescript
Script started, file is typescript
Script done, file is typescript

After:
Script started, file is typescript
Hallo World
Script done, file is typescript
---
 term-utils/script.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/term-utils/script.c b/term-utils/script.c
index 548334c..02ba596 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -269,6 +269,7 @@ main(int argc, char **argv) {
 	sigprocmask(SIG_SETMASK, NULL, &block_mask);
 	sigaddset(&block_mask, SIGCHLD);
 
+	fflush(stdout);
 	sigprocmask(SIG_SETMASK, &block_mask, &unblock_mask);
 	child = fork();
 	sigprocmask(SIG_SETMASK, &unblock_mask, NULL);
-- 
2.2.2

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: sbrabec@suse.cz
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix "Script started" buffering race
  2015-02-06 18:59 [PATCH] Fix "Script started" buffering race Stanislav Brabec
@ 2015-02-10 10:28 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-02-10 10:28 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: Util-Linux

On Fri, Feb 06, 2015 at 07:59:14PM +0100, Stanislav Brabec wrote:
> Before:
> Hallo World
> Script started, file is typescript
> Script started, file is typescript
> Script done, file is typescript
> 
> After:
> Script started, file is typescript
> Hallo World
> Script done, file is typescript

 Applied, thanks.


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-10 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 18:59 [PATCH] Fix "Script started" buffering race Stanislav Brabec
2015-02-10 10:28 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).