From 0789d31aa354ae72b3d760855811623a0bf39b59 Mon Sep 17 00:00:00 2001 From: mjacob Date: Mon, 17 Jul 2000 02:05:45 +0000 Subject: Clean up after oneself on exit. --- share/examples/scsi_target/scsi_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'share/examples') diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index 8e97585..ae5a8e4 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -149,6 +149,7 @@ main(int argc, char *argv[]) if (ioctl(targfd, TARGIODEBUG, &debug) == -1) { perror("TARGIODEBUG"); + (void) ioctl(targctlfd, TARGCTLIOFREEUNIT, &alloc_unit); exit(EX_SOFTWARE); } @@ -156,6 +157,11 @@ main(int argc, char *argv[]) if (buf == NULL) { fprintf(stderr, "%s: Could not malloc I/O buffer", appname); + if (debug) { + debug = 0; + (void) ioctl(targfd, TARGIODEBUG, &debug); + } + (void) ioctl(targctlfd, TARGCTLIOFREEUNIT, &alloc_unit); exit(EX_OSERR); } @@ -173,6 +179,10 @@ main(int argc, char *argv[]) static void cleanup() { + if (debug) { + debug = 0; + (void) ioctl(targfd, TARGIODEBUG, &debug); + } close(targfd); if (ioctl(targctlfd, TARGCTLIOFREEUNIT, &alloc_unit) == -1) { -- cgit v1.1