Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

1 1 was a race-horse, 2 2 was 1 2. When 1 1 1 1 race, 2 2 1 1 2.


devel / comp.lang.postscript / Reading from %pipe% blocks if the program writes only a few output

SubjectAuthor
* Reading from %pipe% blocks if the program writes only a few outputnews
+* Re: Reading from %pipe% blocks if the program writes only a fewJohn Reiser
|`- Re: Reading from %pipe% blocks if the program writes only a few outputnews
`* Re: Reading from %pipe% blocks if the program writes only a few output (example)news
 `* Re: Reading from %pipe% blocks if the program writes only a fewluser droog
  `* Re: Reading from %pipe% blocks if the program writes only a few output (example)news
   `* Re: Reading from %pipe% blocks if the program writes only a few output (example)luser droog
    `- Re: Reading from %pipe% blocks if the program writes only a fewluser droog

1
Reading from %pipe% blocks if the program writes only a few output

<1641626040.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=110&group=comp.lang.postscript#110

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: Reading from %pipe% blocks if the program writes only a few output
Date: Fri, 07 Jan 2022 23:16:57 -0800
Organization: Aioe.org NNTP Server
Message-ID: <1641626040.bystand@zzo38computer.org>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="42367"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.3.0pre
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Sat, 8 Jan 2022 07:16 UTC

If you use %pipe% with a program that writes only a few bytes of output and
then is not finished yet, then the PostScript code will not be able to read
it immediately. The %stdin device does not do that; it will read it
immediately. How to fix so that it can be done by a pipe called by the
PostScript program, also, instead of only stdin?

--
Don't laugh at the moon when it is day time in France.

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

<zpCdnTXKXLGRGEb8nZ2dnUU7_83NnZ2d@giganews.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=111&group=comp.lang.postscript#111

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 09 Jan 2022 18:59:56 -0600
Date: Sun, 9 Jan 2022 16:59:12 -0800
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.3.0
Subject: Re: Reading from %pipe% blocks if the program writes only a few
output
Content-Language: en-US
Newsgroups: comp.lang.postscript
References: <1641626040.bystand@zzo38computer.org>
From: vendor@BitWagon.com (John Reiser)
In-Reply-To: <1641626040.bystand@zzo38computer.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <zpCdnTXKXLGRGEb8nZ2dnUU7_83NnZ2d@giganews.com>
Lines: 6
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-m7E5U18oqCmxWkU09wBelI2YChutID76sedVGPHPqNsGGen9KZlqJ54GP/K9kB7JvOldt1ZW0POKz+R!ve5Y3MasIMaNvTG14zaAo1edMi0hP/xfGU/spti2gN7pcZtrMuYuy4+rBXMEx5za62FfXp7fbWs=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1548
 by: John Reiser - Mon, 10 Jan 2022 00:59 UTC

> If you use %pipe% with a program that writes only a few bytes of output and
> then is not finished yet, then the PostScript code will not be able to read
> it immediately.

Sounds like the writing PostScript process should use 'flush' or '(%stdout%) flushfile'
to force the few bytes into the file from the output buffer.

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

<1641867519.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=112&group=comp.lang.postscript#112

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: Re: Reading from %pipe% blocks if the program writes only a few output
Date: Mon, 10 Jan 2022 18:21:16 -0800
Organization: Aioe.org NNTP Server
Message-ID: <1641867519.bystand@zzo38computer.org>
References: <1641626040.bystand@zzo38computer.org> <zpCdnTXKXLGRGEb8nZ2dnUU7_83NnZ2d@giganews.com>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="41039"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.3.0pre
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Tue, 11 Jan 2022 02:21 UTC

John Reiser <vendor@BitWagon.com> wrote:
> Sounds like the writing PostScript process should use 'flush' or '(%stdout%) flushfile'
> to force the few bytes into the file from the output buffer.

The writing process is not a PostScript program, but a C program; the
PostScript program is reading the output from it. (Note that it does
not do this with standard input (even if it is connected to the same
C program); it only does this with a pipe. (The C program does flush
the output. The PostScript program is doing input; it does flush stdout
but that doesn't affect the %pipe% at all.)

--
Don't laugh at the moon when it is day time in France.

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

<1641945002.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=113&group=comp.lang.postscript#113

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: Re: Reading from %pipe% blocks if the program writes only a few output (example)
Date: Tue, 11 Jan 2022 15:56:35 -0800
Organization: Aioe.org NNTP Server
Message-ID: <1641945002.bystand@zzo38computer.org>
References: <1641626040.bystand@zzo38computer.org>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="39265"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.3.0pre
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Tue, 11 Jan 2022 23:56 UTC

Perhaps I should provide a example:

(%pipe%echo -n 1; sleep 1; echo -n 2; xkbbell; sleep 1; echo -n 3)
(r) file read pstack flush

The expectation should be that the first byte (49) should be readable
right away, and then after one second is a bell and the second byte is
readable, etc.

That isn't what it does; instead it executes (including the bell after
one second), but only after two seconds (when the program specified in
the pipe is terminated) will it be readable.

It works as expected if it is read from %stdin (piping it to Ghostscript,
given suitable PostScript code) instead of %pipe%, though.

--
Don't laugh at the moon when it is day time in France.

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

<32a0aa56-a58e-467d-86e4-868a901bf563n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=114&group=comp.lang.postscript#114

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a05:6214:20ea:: with SMTP id 10mr16622919qvk.94.1642376184059;
Sun, 16 Jan 2022 15:36:24 -0800 (PST)
X-Received: by 2002:a05:6808:19a9:: with SMTP id bj41mr3407176oib.98.1642376183846;
Sun, 16 Jan 2022 15:36:23 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Sun, 16 Jan 2022 15:36:23 -0800 (PST)
In-Reply-To: <1641945002.bystand@zzo38computer.org>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <1641626040.bystand@zzo38computer.org> <1641945002.bystand@zzo38computer.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <32a0aa56-a58e-467d-86e4-868a901bf563n@googlegroups.com>
Subject: Re: Reading from %pipe% blocks if the program writes only a few
output (example)
From: luser.droog@gmail.com (luser droog)
Injection-Date: Sun, 16 Jan 2022 23:36:24 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: luser droog - Sun, 16 Jan 2022 23:36 UTC

On Tuesday, January 11, 2022 at 5:57:41 PM UTC-6, ne...@zzo38computer.org.invalid wrote:
> Perhaps I should provide a example:
>
> (%pipe%echo -n 1; sleep 1; echo -n 2; xkbbell; sleep 1; echo -n 3)
> (r) file read pstack flush
>
> The expectation should be that the first byte (49) should be readable
> right away, and then after one second is a bell and the second byte is
> readable, etc.
>
> That isn't what it does; instead it executes (including the bell after
> one second), but only after two seconds (when the program specified in
> the pipe is terminated) will it be readable.
>
> It works as expected if it is read from %stdin (piping it to Ghostscript,
> given suitable PostScript code) instead of %pipe%, though.

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.

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

<1642446695.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=115&group=comp.lang.postscript#115

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: Re: Reading from %pipe% blocks if the program writes only a few output (example)
Date: Thu, 20 Jan 2022 01:12:52 -0800
Organization: Aioe.org NNTP Server
Message-ID: <1642446695.bystand@zzo38computer.org>
References: <1641626040.bystand@zzo38computer.org> <1641945002.bystand@zzo38computer.org> <32a0aa56-a58e-467d-86e4-868a901bf563n@googlegroups.com>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="53661"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.3.0pre
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Thu, 20 Jan 2022 09:12 UTC

luser droog <luser.droog@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.

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

<466eb2a4-38ce-4ef4-a697-47ed25050860n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=116&group=comp.lang.postscript#116

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a05:620a:29d2:: with SMTP id s18mr1198733qkp.604.1642726603950; Thu, 20 Jan 2022 16:56:43 -0800 (PST)
X-Received: by 2002:a4a:982e:: with SMTP id y43mr1062747ooi.57.1642726603588; Thu, 20 Jan 2022 16:56:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Thu, 20 Jan 2022 16:56:43 -0800 (PST)
In-Reply-To: <1642446695.bystand@zzo38computer.org>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <1641626040.bystand@zzo38computer.org> <1641945002.bystand@zzo38computer.org> <32a0aa56-a58e-467d-86e4-868a901bf563n@googlegroups.com> <1642446695.bystand@zzo38computer.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <466eb2a4-38ce-4ef4-a697-47ed25050860n@googlegroups.com>
Subject: Re: Reading from %pipe% blocks if the program writes only a few output (example)
From: luser.droog@gmail.com (luser droog)
Injection-Date: Fri, 21 Jan 2022 00:56:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 37
 by: luser droog - Fri, 21 Jan 2022 00:56 UTC

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."

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.

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

<f9c45c77-e641-4412-8c7d-399dfd0b3dc6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=130&group=comp.lang.postscript#130

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:ac8:44cb:: with SMTP id b11mr13436222qto.567.1643045340893;
Mon, 24 Jan 2022 09:29:00 -0800 (PST)
X-Received: by 2002:a05:6830:54e:: with SMTP id l14mr3197352otb.138.1643045340603;
Mon, 24 Jan 2022 09:29:00 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Mon, 24 Jan 2022 09:29:00 -0800 (PST)
In-Reply-To: <466eb2a4-38ce-4ef4-a697-47ed25050860n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f9c45c77-e641-4412-8c7d-399dfd0b3dc6n@googlegroups.com>
Subject: Re: Reading from %pipe% blocks if the program writes only a few
output (example)
From: luser.droog@gmail.com (luser droog)
Injection-Date: Mon, 24 Jan 2022 17:29:00 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3730
 by: luser droog - Mon, 24 Jan 2022 17:29 UTC

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.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor