aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorPeter Dufault <dufault@FreeBSD.org>1995-07-11 09:21:33 +0000
committerPeter Dufault <dufault@FreeBSD.org>1995-07-11 09:21:33 +0000
commitca4b4242c962d10b0593e5b97aa894e25f724a3a (patch)
tree8f717d0c2e21d2ff7b87168637ff9f09221ab43e /sbin
parent7c3041774ad33322490a16085d1627771f2284ac (diff)
downloadsrc-ca4b4242c962d10b0593e5b97aa894e25f724a3a.tar.gz
src-ca4b4242c962d10b0593e5b97aa894e25f724a3a.zip
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.
Notes
Notes: svn path=/head/; revision=9480
Diffstat (limited to 'sbin')
-rw-r--r--sbin/scsi/scsi.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/sbin/scsi/scsi.c b/sbin/scsi/scsi.c
index 24ccd9f29ba9..0282131384e6 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 <stdio.h>
@@ -51,6 +51,7 @@
#include <sys/file.h>
#include <scsi.h>
#include <ctype.h>
+#include <signal.h>
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.
*/