Can't close filehandle

2013-05-01 Thread Manfred Lotz
Hi there, I have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. Here is a minimal example where I log a command which fails. snip- #! /usr/bin/perl use strict; use warnings; #use autodie; use

Re: Can't close filehandle

2013-05-01 Thread Ron Bergin
Manfred Lotz wrote: Hi there, I have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. Here is a minimal example where I log a command which fails. snip- #! /usr/bin/perl use strict; use warnings;

Re: Can't close filehandle

2013-05-01 Thread Andy Bach
On Wed, May 1, 2013 at 9:22 AM, Manfred Lotz manfred.l...@arcor.de wrote: have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. If you use the autodie perldoc example code: eval { close($fh); }; if

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 07:58:38 -0700 Ron Bergin r...@i.frys.com wrote: Manfred Lotz wrote: Hi there, I have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. Here is a minimal example where I log a command which fails.

Re: Can't close filehandle

2013-05-01 Thread Brandon McCaig
On Wed, May 01, 2013 at 04:22:42PM +0200, Manfred Lotz wrote: Hi there, Hello, I have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. Here is a minimal example where I log a command which fails.

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 10:04:15 -0500 Andy Bach afb...@gmail.com wrote: On Wed, May 1, 2013 at 9:22 AM, Manfred Lotz manfred.l...@arcor.de wrote: have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. If you use the autodie perldoc example code:

Re: Can't close filehandle

2013-05-01 Thread Brandon McCaig
On Wed, May 01, 2013 at 11:45:00AM -0400, Brandon McCaig wrote: One thing that I know bit me with the 'or die' pattern is that with a pipe if the child process exits with an non-zero exit status then close returns undef, ... Sorry, close returns false to signal failure, not undef. close

Re: Can't close filehandle

2013-05-01 Thread Andy Bach
On Wed, May 1, 2013 at 10:45 AM, Brandon McCaig bamcc...@gmail.com wrote: One thing that I know bit me with the 'or die' pattern is that with a pipe if the child process exits with an non-zero exit status then close returns undef, even though there is really no problem closing the pipe.

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 11:50:05 -0400 Brandon McCaig bamcc...@gmail.com wrote: On Wed, May 01, 2013 at 11:45:00AM -0400, Brandon McCaig wrote: One thing that I know bit me with the 'or die' pattern is that with a pipe if the child process exits with an non-zero exit status then close returns

Re: Can't close filehandle

2013-05-01 Thread Charles DeRykus
... Thanks for your detailed explanations. I think that close should work as I cannot see any reason why a failure of a command closes the pipe prematurely. Actually, everything is ok until the close which checks both the status from reaping the child and the close itself: The open can

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 12:00:18 -0700 Charles DeRykus dery...@gmail.com wrote: ... Thanks for your detailed explanations. I think that close should work as I cannot see any reason why a failure of a command closes the pipe prematurely. Actually, everything is ok until the close which

Re: Can't close filehandle

2013-05-01 Thread Charles DeRykus
On Wed, May 1, 2013 at 12:57 PM, Manfred Lotz manfred.l...@arcor.de wrote: On Wed, 1 May 2013 12:00:18 -0700 Charles DeRykus dery...@gmail.com wrote: ... Thanks for your detailed explanations. I think that close should work as I cannot see any reason why a failure of a command closes

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 14:57:34 -0700 Charles DeRykus dery...@gmail.com wrote: On Wed, May 1, 2013 at 12:57 PM, Manfred Lotz manfred.l...@arcor.de wrote: On Wed, 1 May 2013 12:00:18 -0700 Charles DeRykus dery...@gmail.com wrote: ... Thanks for your detailed explanations. I think