At 4:19 PM -0400 10/22/05, John E. Malmberg wrote:

>>>* Bash shell support.  This needs lots of work.  Pipes need to be fixed.
>> In principle, just replacing my_popen() and my_pclose() in vms/vms.c
>>with another implementation would be all that's needed.  Also,
>>Perl_my_waitpid() would need some work.  I think the choice of a pipe
>>implementation should be a configure-time option, though, as folks on
>>older versions of VMS will  probably be best served by what we've got
>>now, and in fact there's no proof as yet that currently available
>>alternatives are better.
>
>Actually what Perl has is not too bad, and is much better than the pipe 
>implementation in the C library.  I recently used what I had learned about how 
>perl works to implement a fix to Bash to eliminate the RWMBX hangs while 
>running configure scripts.

Cool.  Chuck Lane gets all the credit for Perl's pipe implementation,
and he was driven to it by exactly the types of hangs you describe.

>What I need to do is find out where the extra newlines are being added, 
>because when I recreated the algorithm for bash, I did not end up with extra 
>new lines.  I also do not seem to be having the problem with truncated lines 
>either.

As I understand the problem, there is a fundamental gotcha when
implementing a stream-oriented interface using a record-oriented
gizmo like a mailbox, or at least there is when the main purpose is
inter-process communication.  You can emulate streams to some extent
by using buffering, so that you accumulate writes until you see a
newline character, at which point you do the actual write, creating a
record in the mailbox only when you want the reader to see a record
boundary.  But sometimes you have to flush your buffer or you will
end up with hangs while the reader sits around waiting for a write
that has been buffered.  And of course your buffer will sometimes
fill up and you have to go ahead and write it out before you have a
complete record.

My guess, though I've never pinned it down and watched it happen in
the debugger, is that when we see spurious newlines, it's because a
flush has taken place or the buffer has filled up.  There is lots and
lots of flushing in the Perl test suite; you may just not have as
much flushing in what you're doing with bash.
-- 
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to