New option -signal_handling

This commit is contained in:
Thomas Schmitt 2011-04-23 15:23:35 +00:00
parent f860e24e58
commit fd0b9bb937
15 changed files with 260 additions and 56 deletions

View File

@ -239,6 +239,7 @@ Xorriso_option_setfacl_listi;
Xorriso_option_setfattri;
Xorriso_option_setfattr_listi;
Xorriso_option_set_filter;
Xorriso_option_signal_handling;
Xorriso_option_speed;
Xorriso_option_split_size;
Xorriso_option_status;

View File

@ -624,7 +624,7 @@ int Xorriso_new_hln_array(struct XorrisO *xorriso, off_t mem_limit, int flag)
int Xorriso__preset_signal_behavior(int behavior, int flag)
{
if(behavior < 0 || behavior > 1)
if(behavior < 0 || behavior > 3)
return(0);
Xorriso_signal_behavioR= behavior;
return(1);

View File

@ -78,22 +78,37 @@ int Xorriso_abort(struct XorrisO *xorriso, int flag)
/* @param flag bit0= asynchronous handling (else catch thread, wait, and exit)
bit1= dealing with MMC drive in critical state
behavior 2 -> behavior 1
*/
int Xorriso_set_signal_handling(struct XorrisO *xorriso, int flag)
{
char *handler_prefix= NULL;
int behavior, mode;
if(Xorriso__get_signal_behavior(0) != 1)
behavior= Xorriso__get_signal_behavior(0);
if(behavior == 0)
return(2);
if(behavior == 2 && !(flag & 2))
mode= 1;
else if(behavior == 3)
mode= 2;
else
mode= (flag & 1) * 0x30;
handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1);
if(handler_prefix==NULL) {
sprintf(xorriso->info_text,
"Cannot allocate memory for for setting signal handler");
"Cannot allocate memory for setting signal handler");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
}
/* <<< */
sprintf(xorriso->info_text, "burn_set_signal_handling(%d)", mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
sprintf(handler_prefix, "%s : ", xorriso->progname);
burn_set_signal_handling(handler_prefix, NULL, (flag & 1) * 0x30);
burn_set_signal_handling(handler_prefix, NULL, mode);
free(handler_prefix);
return(1);
}

View File

@ -50,11 +50,6 @@
int Xorriso_abort(struct XorrisO *xorriso, int flag);
/* @param flag bit0= asynchronous handling (else catch thread, wait, and exit)
*/
int Xorriso_set_signal_handling(struct XorrisO *xorriso, int flag);
/* @param flag bit0= suppress messages below UPDATE
bit1= suppress messages below FAILURE
*/

View File

@ -1871,6 +1871,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" exit_value may be 0 or 32 to 63.",
" -report_about severity Set the threshhold for events to be reported.",
" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL",
" -signal_handling \"on\"|\"off\"|\"sig_dfl\"|\"sig_ign\"",
" Handling of signals. Default \"on\" uses libburn handler.",
" -error_behavior \"image_loading\"|\"file_extraction\" behavior",
" Behavior \"best_effort\" is most endurant but may produce",
" results which are correct only on the first glimpse.",

View File

@ -1144,6 +1144,47 @@ ex:;
}
/* Option -signal_handling */
/* @param flag bit0= prescan mode: do not yet install the eventual handler
else: when switching from other modes to "off":
activate mode "sig_dfl"
*/
int Xorriso_option_signal_handling(struct XorrisO *xorriso, char *mode,
int flag)
{
int ret, behavior;
if (strcmp(mode, "off") == 0) {
behavior= Xorriso__get_signal_behavior(0);
if(flag & 1) {
behavior= 0;
} else if(behavior != 0) {
sprintf(xorriso->info_text,
"Signal handling mode \"off\" comes too late. Defaulted to \"sig_dfl\"\n");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
behavior= 2;
}
} else if(strcmp(mode, "libburn") == 0 || strcmp(mode, "on") == 0) {
behavior= 1;
} else if (strcmp(mode, "sig_dfl") == 0) {
behavior= 2;
} else if (strcmp(mode, "sig_ign") == 0) {
behavior= 3;
} else {
sprintf(xorriso->info_text, "-signal_handling: unknown mode '%s'", mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
Xorriso_msgs_submit(xorriso, 0,
"Use one of: \"off\",\"on\",\"sig_dfl\",\"sig_ign\"", 0, "HINT", 0);
return(0);
}
Xorriso__preset_signal_behavior(behavior, 0);
if(flag & 1)
return(1);
ret= Xorriso_set_signal_handling(xorriso, 0);
return(ret);
}
/* Option -speed */
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag)
{

View File

@ -471,7 +471,8 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"preparer_id","print","print_info","print_mark","prompt",
"prog","prog_help","publisher","quoted_not_list","quoted_path_list",
"reassure","report_about","rom_toc_scan","scsi_log",
"session_log","speed","split_size","status","status_history_max",
"session_log","signal_handling",
"speed","split_size","status","status_history_max",
"stdio_sync","stream_recording","system_id","temp_mem_limit",
"uid","unregister_filter","use_readline","volid","volset_id",
"xattr","zisofs",
@ -1295,6 +1296,10 @@ next_command:;
ret= Xorriso_option_set_filter(xorriso, "", argc, argv, idx,
(strcmp(cmd,"show_stream_r")==0) | 2 | 4);
} else if(strcmp(cmd,"signal_handling")==0) {
(*idx)++;
ret= Xorriso_option_signal_handling(xorriso, arg1, 0);
} else if(strcmp(cmd,"speed")==0) {
(*idx)++;
ret= Xorriso_option_speed(xorriso, arg1, 0);
@ -1546,6 +1551,7 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
{
int i, ret, was_dashed, num2, arg_count;
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
int was_signal_handling= 0, was_scsi_log= 0;
char *cmd, *original_cmd, cmd_data[5*SfileadrL], *arg1, *arg2;
char mem_list_delimiter[81];
@ -1644,7 +1650,15 @@ protect_stdout:;
} else if(strcmp(cmd, "scsi_log") == 0 && was_dashed == 1) {
i++;
Xorriso_option_scsi_log(xorriso, arg1, 0);
if(!was_scsi_log)
Xorriso_option_scsi_log(xorriso, arg1, 0);
was_scsi_log= 1;
} else if(strcmp(cmd, "signal_handling") == 0 && was_dashed == 1) {
i++;
if(!was_signal_handling)
Xorriso_option_signal_handling(xorriso, arg1, 1); /* no install */
was_signal_handling= 1;
} else {
ret= Xorriso_count_args(xorriso, argc-i, argv+i, &arg_count, 1);

View File

@ -1082,7 +1082,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
-options_from_file:${resume_state_file}_pos
*/
{
int is_default, no_defaults, i, ret, adr_mode, do_single;
int is_default, no_defaults, i, ret, adr_mode, do_single, behavior;
int show_indev= 1, show_outdev= 1, show_dev= 0;
int part_table_implicit= 0;
char *line, sfe[5 * SfileadrL + 80], mode[80], *form, *treatment;
@ -1201,6 +1201,19 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
behavior= Xorriso__get_signal_behavior(0);
is_default= (behavior == 1);
treatment= "on";
if(behavior == 0)
treatment= "off";
else if(behavior == 2)
treatment= "sig_dfl";
else if(behavior == 3)
treatment= "sig_ign";
sprintf(line,"-signal_handling %s\n", treatment);
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->img_read_error_mode==2);
treatment= "best_effort";
if(xorriso->img_read_error_mode==1)

View File

@ -554,7 +554,7 @@ ex:;
int Xorriso_write_session(struct XorrisO *xorriso, int flag)
{
int ret, relax= 0, i, pacifier_speed= 0, data_lba, ext, is_bootable= 0;
int freshly_bootable= 0, hide_attr, pad_by_libisofs= 0;
int freshly_bootable= 0, hide_attr, pad_by_libisofs= 0, signal_mode;
char xorriso_id[256], *img_id, sfe[5*SfileadrL], *out_cs, *part_image;
struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo;
@ -926,7 +926,12 @@ fprintf(stderr, "XORRISO_DEBUG: isoburn_igopt_set_tail_blocks(%d)\n",
goto cancel_iso;
/* Important: do not return until burn_is_aborting() was checked */
Xorriso_set_signal_handling(xorriso, 1);
signal_mode= 1;
ret= burn_drive_get_drive_role(drive);
if(ret == 1)
signal_mode|= 2;
Xorriso_set_signal_handling(xorriso, signal_mode);
/* De-activate eventual target file truncation in dummy mode */
ret= isoburn_set_truncate(drive, (!xorriso->do_dummy) | 2 | 4);
@ -1253,7 +1258,7 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
*/
int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
{
int ret, do_deformat= 0;
int ret, do_deformat= 0, signal_mode;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status disc_state;
@ -1322,7 +1327,11 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
Xorriso_info(xorriso,0);
/* Important: do not return until burn_is_aborting() was checked */
Xorriso_set_signal_handling(xorriso, 1);
signal_mode= 1;
ret= burn_drive_get_drive_role(drive);
if(ret == 1)
signal_mode|= 2;
Xorriso_set_signal_handling(xorriso, signal_mode);
if(do_deformat)
burn_disc_erase(drive, (flag&1));
@ -1370,7 +1379,7 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
*/
int Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag)
{
int ret, mode_flag= 0, index, status, num_formats;
int ret, mode_flag= 0, index, status, num_formats, signal_mode;
unsigned dummy;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
@ -1481,7 +1490,11 @@ int Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag)
size= in_size;
/* Important: do not return until burn_is_aborting() was checked */
Xorriso_set_signal_handling(xorriso, 1);
signal_mode= 1;
ret= burn_drive_get_drive_role(drive);
if(ret == 1)
signal_mode|= 2;
Xorriso_set_signal_handling(xorriso, signal_mode);
burn_disc_format(drive, size, mode_flag);
@ -1612,8 +1625,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
char *track_source, off_t tsize, int flag)
{
int ret, fd, unpredicted_size, profile_number, is_cd= 0, dummy, nwa= -1;
int isosize= -1, do_isosize, is_bd= 0;
int isosize= -1, do_isosize, is_bd= 0, signal_mode;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
struct burn_write_opts *burn_options;
@ -1812,7 +1824,11 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
goto ex;
/* Important: do not return until burn_is_aborting() was checked */
Xorriso_set_signal_handling(xorriso, 1);
signal_mode= 1;
ret= burn_drive_get_drive_role(drive);
if(ret == 1)
signal_mode|= 2;
Xorriso_set_signal_handling(xorriso, signal_mode);
xorriso->run_state= 1; /* Indicate that burning has started */
burn_disc_write(burn_options, disc);

View File

@ -9,7 +9,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Apr 03, 2011"
.TH XORRISO 1 "Apr 22, 2011"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -2870,6 +2870,36 @@ A special property of this option is that the first -report_about setting
among the start arguments is in effect already when the first operations
of xorriso begin. Only "-report_about" with dash "-" is recognized that way.
.TP
\fB\-signal_handling\fR mode
Control the installation of a signal handler which shall react on external
signals (e.g. from program "kill" or from keys Ctrl+C) or on signals
caused by severe program errors.
.br
Mode "on" is the default. It uses the signal handler of libburn which produces
ugly messages but puts much effort in releasing eventually used optical drives
before xorriso ends.
.br
Mode "off" as first -signal_handling among the start arguments prevents all
own signal precautions of xorriso. Eventually inherited signal handler settings
stay as they are.
.br
It works like "sig_dfl" if given after other signal handling was already
established at program start.
.br
Mode "sig_dfl" uses the system provided default handling of signals, which is
normally a sudden abort of the program. To prevent stuck drives, the
libburn handler is used during burning, blanking, and formatting on MMC drives.
.br
Mode "sig_ign" tries to ignore as many signal types as possible. This imposes
the risk that xorriso refuses to end until externally kill -9 if performed.
kill -9 then imposes the risk that the drive is left in unusable state and
needs poweroff to be reset. So during burning, blanking, and formatting
wait for at least their normal run time before killing externally.
.br
A special property of this option is that the first -signal_handling setting
among the start arguments is in effect already when the first operations
of xorriso begin. Only "-signal_handling" with dash "-" is recognized that way.
.TP
\fB\-error_behavior\fR occasion behavior
Control the program behavior at problem event occasions.
For now this applies to occasions "image_loading" which is given while

View File

@ -136,6 +136,10 @@ char *Xorriso__get_patch_level_text(int flag);
1= use libburn signal handler. Most time with action
0. During writing, formatting, blanking: 0x30.
Only usable with a single xorriso object.
2= Enable system default reaction on all signals
@since 1.0.9
3= Try to ignore nearly all signals
@since 1.0.9
@param flag unused yet, submit 0
@return <= 0 is error, >0 is success
*/
@ -1147,6 +1151,12 @@ int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path,
int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name,
int argc, char **argv, int *idx, int flag);
/* Option -signal_handling */
/* @param flag bit0= do not yet install the eventual handler
*/
int Xorriso_option_signal_handling(struct XorrisO *xorriso, char *mode,
int flag);
/* Option -speed */
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag);

View File

@ -2537,6 +2537,33 @@ failed unexpectedly.
first operations of xorriso begin. Only "-report_about" with dash
"-" is recognized that way.
-signal_handling mode
Control the installation of a signal handler which shall react on
external signals (e.g. from program "kill" or from keys Ctrl+C) or
on signals caused by severe program errors.
Mode "on" is the default. It uses the signal handler of libburn
which produces ugly messages but puts much effort in releasing
eventually used optical drives before xorriso ends.
Mode "off" as first -signal_handling among the start arguments
prevents all own signal precautions of xorriso. Eventually
inherited signal handler settings stay as they are.
It works like "sig_dfl" if given after other signal handling was
already established at program start.
Mode "sig_dfl" uses the system provided default handling of
signals, which is normally a sudden abort of the program. To
prevent stuck drives, the libburn handler is used during burning,
blanking, and formatting on MMC drives.
Mode "sig_ign" tries to ignore as many signal types as possible.
This imposes the risk that xorriso refuses to end until externally
kill -9 if performed. kill -9 then imposes the risk that the
drive is left in unusable state and needs poweroff to be reset. So
during burning, blanking, and formatting wait for at least their
normal run time before killing externally.
A special property of this option is that the first
-signal_handling setting among the start arguments is in effect
already when the first operations of xorriso begin. Only
"-signal_handling" with dash "-" is recognized that way.
-error_behavior occasion behavior
Control the program behavior at problem event occasions. For now
this applies to occasions "image_loading" which is given while an
@ -4173,7 +4200,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -eject ejects drive tray: Writing. (line 36)
* -end writes pending session and ends program: Scripting. (line 134)
* -errfile_log logs problematic disk files: Scripting. (line 96)
* -error_behavior controls error workarounds: Exception. (line 69)
* -error_behavior controls error workarounds: Exception. (line 96)
* -external_filter registers data filter: Filter. (line 20)
* -external_filter unregisters data filter: Filter. (line 48)
* -extract copies file tree to disk: Restore. (line 56)
@ -4282,6 +4309,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -setfattr_r sets xattr in ISO image: Manip. (line 123)
* -show_stream shows data source and filters: Navigate. (line 162)
* -show_stream_r shows data source and filters: Navigate. (line 177)
* -signal_handling controls handling of system signals: Exception.
(line 69)
* -speed set write speed: SetWrite. (line 211)
* -split_size enables large file splitting: SetInsert. (line 140)
* -status shows current settings: Scripting. (line 29)
@ -4338,6 +4367,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Character Set, of terminal, -local_charset: Charset. (line 47)
* Closed media, _definition: Media. (line 43)
* Comment, #: Scripting. (line 140)
* Control, signal handling, -signal_handling: Exception. (line 69)
* Create, new ISO image, _definiton: Methods. (line 6)
* Cylinder alignment, _definiton: Bootable. (line 169)
* Cylinder size, _definiton: Bootable. (line 158)
@ -4476,7 +4506,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Process, disable startup files, -no_rc: Scripting. (line 7)
* Process, end program and write, -end: Scripting. (line 134)
* Process, end program, no writing, -rollback_end: Scripting. (line 137)
* Process, error workarounds, -error_behavior: Exception. (line 69)
* Process, error workarounds, -error_behavior: Exception. (line 96)
* Process, log output channels to file, -logfile: Frontend. (line 20)
* Process, read command file, -options_from_file: Scripting. (line 12)
* Process, set synchronizing message, -mark: Frontend. (line 25)
@ -4583,35 +4613,35 @@ Node: Bootable104898
Node: Jigdo118216
Node: Charset122474
Node: Exception125225
Node: DialogCtl129736
Node: Inquiry132323
Node: Navigate136700
Node: Verify144640
Node: Restore153229
Node: Emulation159885
Node: Scripting169721
Node: Frontend175861
Node: Examples177156
Node: ExDevices178325
Node: ExCreate178959
Node: ExDialog180233
Node: ExGrowing181495
Node: ExModifying182297
Node: ExBootable182798
Node: ExCharset183345
Node: ExPseudo184173
Node: ExCdrecord185067
Node: ExMkisofs185382
Node: ExGrowisofs186718
Node: ExException187842
Node: ExTime188296
Node: ExIncBackup188755
Node: ExRestore192676
Node: ExRecovery193645
Node: Files194211
Node: Seealso195501
Node: Legal196081
Node: CommandIdx197003
Node: ConceptIdx211529
Node: DialogCtl131343
Node: Inquiry133930
Node: Navigate138307
Node: Verify146247
Node: Restore154836
Node: Emulation161492
Node: Scripting171328
Node: Frontend177468
Node: Examples178763
Node: ExDevices179932
Node: ExCreate180566
Node: ExDialog181840
Node: ExGrowing183102
Node: ExModifying183904
Node: ExBootable184405
Node: ExCharset184952
Node: ExPseudo185780
Node: ExCdrecord186674
Node: ExMkisofs186989
Node: ExGrowisofs188325
Node: ExException189449
Node: ExTime189903
Node: ExIncBackup190362
Node: ExRestore194283
Node: ExRecovery195252
Node: Files195818
Node: Seealso197108
Node: Legal197688
Node: CommandIdx198610
Node: ConceptIdx213278

End Tag Table

View File

@ -44,7 +44,7 @@
@c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISO 1 "Apr 03, 2011"
@c man .TH XORRISO 1 "Apr 22, 2011"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -3382,6 +3382,38 @@ A special property of this option is that the first -report_about setting
among the start arguments is in effect already when the first operations
of xorriso begin. Only "-report_about" with dash "-" is recognized that way.
@c man .TP
@item -signal_handling mode
@kindex -signal_handling controls handling of system signals
@cindex Control, signal handling, -signal_handling
Control the installation of a signal handler which shall react on external
signals (e.g. from program "kill" or from keys Ctrl+C) or on signals
caused by severe program errors.
@*
Mode "on" is the default. It uses the signal handler of libburn which produces
ugly messages but puts much effort in releasing eventually used optical drives
before xorriso ends.
@*
Mode "off" as first -signal_handling among the start arguments prevents all
own signal precautions of xorriso. Eventually inherited signal handler settings
stay as they are.
@*
It works like "sig_dfl" if given after other signal handling was already
established at program start.
@*
Mode "sig_dfl" uses the system provided default handling of signals, which is
normally a sudden abort of the program. To prevent stuck drives, the
libburn handler is used during burning, blanking, and formatting on MMC drives.
@*
Mode "sig_ign" tries to ignore as many signal types as possible. This imposes
the risk that xorriso refuses to end until externally kill -9 if performed.
kill -9 then imposes the risk that the drive is left in unusable state and
needs poweroff to be reset. So during burning, blanking, and formatting
wait for at least their normal run time before killing externally.
@*
A special property of this option is that the first -signal_handling setting
among the start arguments is in effect already when the first operations
of xorriso begin. Only "-signal_handling" with dash "-" is recognized that way.
@c man .TP
@item -error_behavior occasion behavior
@kindex -error_behavior controls error workarounds
@cindex Process, error workarounds, -error_behavior

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.04.22.081847"
#define Xorriso_timestamP "2011.04.23.152348"

View File

@ -570,5 +570,10 @@ int Xorriso_clone_under(struct XorrisO *xorriso, char *origin, char *dest,
int Xorriso_mark_update_merge(struct XorrisO *xorriso, char *path,
void *node, int flag);
/* @param flag bit0= asynchronous handling (else catch thread, wait, and exit)
*/
int Xorriso_set_signal_handling(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */