--- buffer.c.original Sun Jun 11 18:40:11 2000 +++ buffer.c Sat Sep 30 00:03:23 2000 @@ -77,6 +77,11 @@ static void write_error PARAMS ((int)); static void read_error PARAMS ((void)); +/* The signal-file info */ +extern int use_signal_file; /* 1 if we should use the signal file in */ + /* preference to the usual tty method */ +extern char signal_file[]; /* the name of the signal file. */ + #if !MSDOS /* Obnoxious test to see if dimwit is trying to dump the archive. */ dev_t ar_dev; @@ -1502,9 +1507,11 @@ static FILE *read_file = NULL; static int looped = 0; + + FILE *sfile_p; int status; - if (!read_file && !info_script_option) + if (!read_file && !info_script_option && !use_signal_file) /* FIXME: if fopen is used, it will never be closed. */ read_file = archive == STDIN ? fopen (TTY_NAME, "r") : stdin; @@ -1541,23 +1548,42 @@ while (1) { char input_buffer[80]; - - fprintf (stderr, - _("\007Prepare volume #%d for %s and hit return: "), - global_volno, *archive_name_cursor); - fflush (stderr); - - if (fgets (input_buffer, sizeof (input_buffer), read_file) == 0) - { - fprintf (stderr, _("EOF where user reply was expected")); - - if (subcommand_option != EXTRACT_SUBCOMMAND - && subcommand_option != LIST_SUBCOMMAND - && subcommand_option != DIFF_SUBCOMMAND) - WARN ((0, 0, _("WARNING: Archive is incomplete"))); - - exit (TAREXIT_FAILURE); + if (use_signal_file) { + fprintf (stderr, + _("Prepare volume #%d for %s\n"), + global_volno, *archive_name_cursor); + fflush (stderr); + /* read input from signal file when it arrives */ + input_buffer[0] = 'q'; + input_buffer[1] = '\0'; + while (1) { + sfile_p = fopen(signal_file,"r"); + if (sfile_p) { + fgets (input_buffer, 2, sfile_p); + fclose(sfile_p); + unlink(signal_file); + fprintf (stderr, _("file %s found - continuing (%s)\n"), signal_file, input_buffer); + fflush(stderr); + break; + }; + sleep(10); + fprintf (stderr, _(">") ); + fflush (stderr); } + } else { + + if (fgets (input_buffer, sizeof (input_buffer), read_file) == 0) + { + fprintf (stderr, _("EOF where user reply was expected")); + + if (subcommand_option != EXTRACT_SUBCOMMAND + && subcommand_option != LIST_SUBCOMMAND + && subcommand_option != DIFF_SUBCOMMAND) + WARN ((0, 0, _("WARNING: Archive is incomplete"))); + + exit (TAREXIT_FAILURE); + } + } if (input_buffer[0] == '\n' || input_buffer[0] == 'y' || input_buffer[0] == 'Y')