aboutsummaryrefslogtreecommitdiff
path: root/src/idop.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-03-20 13:06:46 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-03-20 13:06:46 +0200
commit929d8a0d47e8741093bbfd024715a1c7a08cae9e (patch)
treed1d5d0f01e43e265d4b870fb81a3e822237eca09 /src/idop.c
parent764d7a8a1204ad4a623a051e1751d5809c40b8a8 (diff)
downloadidest-929d8a0d47e8741093bbfd024715a1c7a08cae9e.tar.gz
idest-929d8a0d47e8741093bbfd024715a1c7a08cae9e.tar.bz2
Improve signal handling; new option --verbose
* NEWS: Update. * src/cmdline.opt: New option --version * src/idop.c (safe_id3_file_update_and_close): New function. (set_tags, del_tags): Use safe_id3_file_update_and_close. * src/main.c (verbose_option): New variable. (main): Print name of the file being processed, if verbose_option is set.
Diffstat (limited to 'src/idop.c')
-rw-r--r--src/idop.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/idop.c b/src/idop.c
index 07b4601..f7d9d4e 100644
--- a/src/idop.c
+++ b/src/idop.c
@@ -17,2 +17,3 @@
#include "idest.h"
+#include <signal.h>
@@ -73,2 +74,17 @@ set_frame_value(struct id3_frame *frame, const char *value)
void
+safe_id3_file_update_and_close(struct id3_file *file)
+{
+ sigset_t set, oldset;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGTERM);
+
+ sigprocmask(SIG_BLOCK, &set, &oldset);
+ id3_file_update(file);
+ id3_file_close(file);
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
+}
+
+void
set_tags(const char *name)
@@ -131,4 +147,5 @@ set_tags(const char *name)
if (modified)
- id3_file_update(file);
- id3_file_close(file);
+ safe_id3_file_update_and_close(file);
+ else
+ id3_file_close(file);
}
@@ -150,4 +167,3 @@ del_tags(const char *name)
ID3_TAG_OPTION_NO_ID3V2);
- id3_file_update(file);
- id3_file_close(file);
+ safe_id3_file_update_and_close(file);
}

Return to:

Send suggestions and report system problems to the System administrator.