[Ltrace-devel] [PATCH] ltrace doesn't call fclose when it exits.
GuiJianfeng
jianfenggui at gmail.com
Sun Oct 21 08:43:37 UTC 2007
Rodrigo Rubira Branco 写道:
> On Mon, 2007-08-06 at 21:52 +0800, GuiJianfeng wrote:
>> Hi all,
>>
>> I find that ltrace doesn't call fclose() to close the output file when
>> use option "-o".
>> I think that might be a bug.
>
> Why not just use the output value in the tests instead of create an
> opt_o option?
follow the coding style of ltrace :-)
>
> cya,
>
>
> Rodrigo (BSDaemon).
>
>>
>> diff -Narup ltrace-0.5/ltrace.c ltrace-0.5.prep/ltrace.c
>> --- ltrace-0.5/ltrace.c 2007-08-03 04:55:15.000000000 +0800
>> +++ ltrace-0.5.prep/ltrace.c 2007-08-04 22:07:40.000000000 +0800
>> @@ -54,6 +54,10 @@ static void signal_exit(int sig)
>> {
>> exiting = 1;
>> debug(1, "Received interrupt signal; exiting...");
>> + if (opt_o) {
>> + fclose(output);
>> + }
>> +
>> signal(SIGINT, SIG_IGN);
>> signal(SIGTERM, SIG_IGN);
>> signal(SIGALRM, signal_alarm);
>> @@ -74,6 +78,9 @@ static void normal_exit(void)
>> if (opt_c) {
>> show_summary();
>> }
>> + if (opt_o) {
>> + fclose(output);
>> + }
>> }
>>
>> static void guess_cols(void)
>> diff -Narup ltrace-0.5/options.c ltrace-0.5.prep/options.c
>> --- ltrace-0.5/options.c 2007-08-03 04:55:15.000000000 +0800
>> +++ ltrace-0.5.prep/options.c 2007-08-04 22:07:41.000000000 +0800
>> @@ -42,6 +42,7 @@ int opt_C = 0; /* Demangle
>> low-level s
>> #endif
>> int opt_n = 0; /* indent trace output according to
>> program flow */
>> int opt_T = 0; /* show the time spent inside each call */
>> +int opt_o = 0; /* output to a specific file */
>>
>> /* List of pids given to option -p: */
>> struct opt_p_t *opt_p = NULL; /* attach to process with a given pid */
>> @@ -274,6 +275,7 @@ char **process_options(int argc, char **
>> opt_n = atoi(optarg);
>> break;
>> case 'o':
>> + opt_o++;
>> output = fopen(optarg, "w");
>> if (!output) {
>> fprintf(stderr,
>> diff -Narup ltrace-0.5/options.h ltrace-0.5.prep/options.h
>> --- ltrace-0.5/options.h 2007-08-03 04:55:15.000000000 +0800
>> +++ ltrace-0.5.prep/options.h 2007-08-04 22:07:41.000000000 +0800
>> @@ -20,6 +20,7 @@ extern int opt_t; /* print absolute tim
>> extern int opt_C; /* Demanglelow-level symbol names into
>> user-level names */
>> extern int opt_n; /* indent trace output according to
>> program flow */
>> extern int opt_T; /* show the time spent inside each call */
>> +extern int opt_o; /* output to a specific file */
>>
>> struct opt_p_t {
>> pid_t pid;
>>
>>
>> _______________________________________________
>> Ltrace-devel mailing list
>> Ltrace-devel at lists.alioth.debian.org
>> http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ltrace-devel mailing list
> Ltrace-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel
--
Regards,
Jianfeng Gui
More information about the Ltrace-devel
mailing list