From 6a1dea5dbee367c692654f33a8938f863a27f1da Mon Sep 17 00:00:00 2001 From: dufault Date: Tue, 11 Jul 1995 09:21:33 +0000 Subject: The mode page editor never cleaned up the temp files. Thanks to Joerg for noticing. This low risk bug fix is appropriate for 2.1. --- sbin/scsi/scsi.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'sbin/scsi') diff --git a/sbin/scsi/scsi.c b/sbin/scsi/scsi.c index 24ccd9f..0282131 100644 --- a/sbin/scsi/scsi.c +++ b/sbin/scsi/scsi.c @@ -39,7 +39,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi.c,v 1.7 1995/05/05 20:42:00 dufault Exp $ + * $Id: scsi.c,v 1.8 1995/05/30 06:09:58 rgrimes Exp $ */ #include @@ -51,6 +51,7 @@ #include #include #include +#include int fd; int debuglevel; @@ -573,6 +574,7 @@ struct editinfo } editinfo[64]; /* XXX Bogus fixed size */ static int editind; +volatile int edit_opened; static FILE *edit_file; static char edit_name[L_tmpnam]; @@ -583,6 +585,30 @@ edit_rewind(void) } static void +edit_done(void) +{ + int opened; + + sigset_t all, prev; + sigfillset(&all); + + (void)sigprocmask(SIG_SETMASK, &all, &prev); + + opened = (int)edit_opened; + edit_opened = 0; + + (void)sigprocmask(SIG_SETMASK, &prev, 0); + + if (opened) + { + if (fclose(edit_file)) + perror(edit_name); + if (unlink(edit_name)) + perror(edit_name); + } +} + +static void edit_init(void) { edit_rewind(); @@ -594,6 +620,9 @@ edit_init(void) perror(edit_name); exit(errno); } + edit_opened = 1; + + atexit(edit_done); } static void @@ -778,6 +807,8 @@ mode_edit(int fd, int page, int edit, int argc, char *argv[]) mh->mdl, fmt, arg_put, 0); #endif + edit_done(); + /* Make it permanent if pageselect is three. */ -- cgit v1.1