3232static int res = 0 ;
3333static char * progname ;
3434static pid_t test_pgrp ;
35- static FILE * tty_fp ;
35+ static FILE * out ;
3636
3737static int the_signal = SIGTERM ;
3838
3939static void int_func (int signum )
4040{
41- pounder_fprintf (tty_fp ,
41+ pounder_fprintf (out ,
4242 "%s: Killed by interrupt. Last exit code = %d.\n" ,
4343 progname , res );
4444 kill (- test_pgrp , the_signal );
@@ -47,7 +47,7 @@ static void int_func(int signum)
4747
4848static void alarm_func (int signum )
4949{
50- pounder_fprintf (tty_fp , "%s: Killed by timer. Last exit code = %d.\n" ,
50+ pounder_fprintf (out , "%s: Killed by timer. Last exit code = %d.\n" ,
5151 progname , res );
5252 kill (- test_pgrp , the_signal );
5353 exit (res );
@@ -90,14 +90,7 @@ int main(int argc, char *argv[])
9090 }
9191 }
9292
93- tty_fp = fdopen (3 , "w+" );
94- if (tty_fp == NULL ) {
95- tty_fp = fopen ("/dev/tty" , "w+" );
96- if (tty_fp == NULL ) {
97- perror ("stdout" );
98- exit (2 );
99- }
100- }
93+ out = stdout ;
10194
10295 if (use_max_failures ) {
10396 progname = rindex (argv [7 ], '/' );
@@ -142,11 +135,11 @@ int main(int argc, char *argv[])
142135 gid = atoi (argv [3 ]);
143136 }
144137
145- pounder_fprintf (tty_fp , "%s: uid = %d, gid = %d, sig = %d\n" ,
138+ pounder_fprintf (out , "%s: uid = %d, gid = %d, sig = %d\n" ,
146139 progname , uid , gid , the_signal );
147140
148141 while (1 ) {
149- pounder_fprintf (tty_fp , "%s: %s loop #%d.\n" , progname ,
142+ pounder_fprintf (out , "%s: %s loop #%d.\n" , progname ,
150143 start_msg , revs ++ );
151144 pid = fork ();
152145 if (pid == 0 ) {
@@ -196,22 +189,22 @@ int main(int argc, char *argv[])
196189 }
197190 // interrogate it
198191 if (WIFSIGNALED (stat )) {
199- pounder_fprintf (tty_fp , "%s: %s on signal %d.\n" ,
192+ pounder_fprintf (out , "%s: %s on signal %d.\n" ,
200193 progname , fail_msg , WTERMSIG (stat ));
201194 res = 255 ;
202195 } else {
203196 res = WEXITSTATUS (stat );
204197 if (res == 0 ) {
205- pounder_fprintf (tty_fp , "%s: %s.\n" , progname ,
198+ pounder_fprintf (out , "%s: %s.\n" , progname ,
206199 pass_msg );
207200 } else if (res < 0 || res == 255 ) {
208- pounder_fprintf (tty_fp ,
201+ pounder_fprintf (out ,
209202 "%s: %s with code %d.\n" ,
210203 progname , abort_msg , res );
211204 exit (-1 );
212205 // FIXME: add test to blacklist
213206 } else {
214- pounder_fprintf (tty_fp ,
207+ pounder_fprintf (out ,
215208 "%s: %s with code %d.\n" ,
216209 progname , fail_msg , res );
217210 if (max_failures > 0 ) {
0 commit comments