Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3736

Re: Reading from %pipe% blocks if the program writes only a few output (example)

Newsgroups comp.lang.postscript
Date 2022-01-24 09:29 -0800
References <1641626040.bystand@zzo38computer.org> <1641945002.bystand@zzo38computer.org> <32a0aa56-a58e-467d-86e4-868a901bf563n@googlegroups.com> <1642446695.bystand@zzo38computer.org> <466eb2a4-38ce-4ef4-a697-47ed25050860n@googlegroups.com>
Message-ID <f9c45c77-e641-4412-8c7d-399dfd0b3dc6n@googlegroups.com> (permalink)
Subject Re: Reading from %pipe% blocks if the program writes only a few output (example)
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Thursday, January 20, 2022 at 6:56:44 PM UTC-6, luser droog wrote:
> On Thursday, January 20, 2022 at 3:14:19 AM UTC-6, ne...@zzo38computer.org.invalid wrote: 
> > luser droog <luser...@gmail.com> wrote: 
> > > I may not completely follow what you're ultimately trying to do. But just in 
> > > case you haven't heard of it, there's a little known unix tool called expect(1) 
> > > that was designed to help with these sort of pipe/flushing issues. It was 
> > > written by the same guy that wrote Tcl/tk. 
> > That is not related, and does not help. (I am not sure how else to explain.) 
> > -- 
> > Don't laugh at the moon when it is day time in France.
> Sorry about that. I've read the thread again and done some thinking. 
> But I fear the answer is just as you've discovered. According to 
> https://www.ghostscript.com/doc/current/Language.htm#File 
> 
> " Ghostscript also supports the following IODevice in addition to a subset 
> of those defined in the Adobe documentation: 
> 
> "%pipe%command, which opens a pipe on the given command. This is 
> supported only on operating systems that provide popen (primarily Unix 
> systems, and not all of those)." 
> 
> Then (my local) `man popen` says: 
> 
> " Use popen to create a stream to a child process executing a command string *s as 
> processed by /bin/sh on your system. The argument mode must start with either `r', 
> where the stream reads from the child's stdout, or `w', where the stream writes to 
> the child's stdin. As an extension, mode may also contain `e' to set the 
> close-on-exec bit of the parent's file descriptor. The stream created by popen must 
> be closed by pclose to avoid resource leaks." 
> 

Making sure I'm clear. The following is all guess-work on my part. If any of my
guesses are wrong, my conclusions are probably wrong.

> So, I think ghostscript is using the minimal guarantees that POSIX gives 
> for popen(1) which is that you can read OR write from it. Ghoscript is 
> presumably adding a "> /tmp/$$pipe-output" to your command line, 
> creating a writable pipe, and then giving you a read handle to that temp 
> file later on. That would explain the blocking that you're experiencing. 
> 
> Bad news is I don't see any way to change it except by changing the C code that 
> implements the %pipe% device.

I don't know this for a fact.

Back to comp.lang.postscript | Previous | NextPrevious in thread | Find similar


Thread

Reading from %pipe% blocks if the program writes only a few output news@zzo38computer.org.invalid - 2022-01-07 23:16 -0800
  Re: Reading from %pipe% blocks if the program writes only a few output John Reiser <vendor@BitWagon.com> - 2022-01-09 16:59 -0800
    Re: Reading from %pipe% blocks if the program writes only a few output news@zzo38computer.org.invalid - 2022-01-10 18:21 -0800
  Re: Reading from %pipe% blocks if the program writes only a few output (example) news@zzo38computer.org.invalid - 2022-01-11 15:56 -0800
    Re: Reading from %pipe% blocks if the program writes only a few output (example) luser droog <luser.droog@gmail.com> - 2022-01-16 15:36 -0800
      Re: Reading from %pipe% blocks if the program writes only a few output (example) news@zzo38computer.org.invalid - 2022-01-20 01:12 -0800
        Re: Reading from %pipe% blocks if the program writes only a few output (example) luser droog <luser.droog@gmail.com> - 2022-01-20 16:56 -0800
          Re: Reading from %pipe% blocks if the program writes only a few output (example) luser droog <luser.droog@gmail.com> - 2022-01-24 09:29 -0800

csiph-web