[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exit
From: |
Aharon Robbins |
Subject: |
Re: exit |
Date: |
Thu, 5 Feb 2004 15:47:07 +0200 |
Greetings. Re this:
> Date: Tue, 3 Feb 2004 13:41:16 +0100
> From: address@hidden
> To: address@hidden
> Subject: exit
>
> Hello!
>
> I have a problem with setting return value to zero once it's nonzero. As you
> see setting it to different nonzero value is ok.
>
>
> awk 'BEGIN { "exit 1" | getline dif } END { exit 0 }' < /dev/null; echo $?
> sh: line 1: xxx: command not found
> 1
>
> awk 'BEGIN { "exit 1" | getline dif } END { exit 2 }' < /dev/null; echo $?
> sh: line 1: xxx: command not found
> 2
>
> awk 'BEGIN { "exit 1" | getline dif ; "echo" | getline dif } END { exit 0 }' <
> /dev/null; echo $?
> sh: line 1: xxx: command not found
> 1
>
> awk 'BEGIN { "echo" | getline dif } END { exit 0 }' < /dev/null; echo $?
> 0
>
> awk --version
> GNU Awk 3.1.3
>
>
> I found out that on the end of awk program execution you have
>
> mail.c
>
> if (close_io() != 0 && exit_val == 0)
> exit_val = 1;
>
> probably the filedescriptor remains as open and the function
>
> gawk_pclose
>
> returns the proces status which is of course nonzero
>
> return rp->status;
>
> May be after pipe operation you shoud close and free the descriptor.
>
> So it's up to you to decide if this behavior is OK. But please len me know
> if you consider this as a bug and would solve it or i would have to start to
> use another return code for success as zero.
>
> Thank you very much.
>
> Jozef.
Here is a fix for the bug.
Arnold
-----------------------
Thu Feb 5 15:30:04 2004 Arnold D. Robbins <address@hidden>
* main.c (main): When checking for `close_io' failure, only set
`exit_val' to 1 if not already exiting.
--- ../gawk-3.1.3/main.c 2003-07-07 19:55:27.000000000 +0300
+++ main.c 2004-02-05 15:44:48.000000000 +0200
@@ -569,7 +577,7 @@
(void) interpret(end_block);
}
in_end_rule = FALSE;
- if (close_io() != 0 && exit_val == 0)
+ if (close_io() != 0 && ! exiting && exit_val == 0)
exit_val = 1;
if (do_profiling) {
- exit, jozef . kutej, 2004/02/03
- Re: exit, jozef . kutej, 2004/02/04
- Re: exit, Aharon Robbins, 2004/02/04
- Re: exit,
Aharon Robbins <=