Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1372 > unrolled thread
| Started by | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| First post | 2013-04-25 16:32 -0700 |
| Last post | 2013-04-30 20:26 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.postscript
Make ghostscript signal an /interrupt error when it received a SIGINT luser- -droog <mijoryx@yahoo.com> - 2013-04-25 16:32 -0700
Re: Make ghostscript signal an /interrupt error when it received a SIGINT luser- -droog <mijoryx@yahoo.com> - 2013-04-26 15:33 -0700
Re: Make ghostscript signal an /interrupt error when it received a SIGINT Helge Blischke <h.blischke@acm.org> - 2013-04-30 18:35 +0200
Re: Make ghostscript signal an /interrupt error when it received a SIGINT luser- -droog <mijoryx@yahoo.com> - 2013-04-30 20:26 -0700
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-04-25 16:32 -0700 |
| Subject | Make ghostscript signal an /interrupt error when it received a SIGINT |
| Message-ID | <a167181f-d7b2-4457-94e0-21239c955b6a@googlegroups.com> |
With my Mandelbrot explorer (https://code.google.com/p/xpost/downloads/detail?name=mandel2.ps),
I'd like to be able to interrupt the drawing and return to the menu if
the resolution is too high and it's taking too long.
The PLRM, 1ed, says
> interrupt (error)
> processes an external request to interrupt execution of a PostScript
> program. When the interpreter receives an interrupt request, it executes
> interrupt as if it were an error (i.e. it looks up the name 'interrupt' in
> errordict). Execution of interrupt is sandwiched between execution of
> two objects being interpreted in normal sequence.
> The precise nature of an external interrupt request depends on the en-
> vironment in which the PostScript interpreter is running. In typical
> environments, receipt of a control-C character from a serial communi-
> cation channel gives rise to the interrupt error. This permits a user to
> explicitly abort a PostScript computation. The default definition of
> interrupt executes a stop.
I tried wrapping the drawing functions in a stopped context.
% The Main Loop
% - draw the object according to currrent parameters
% - enter menu loop
% - showpage
{
{
createtable findmaxmin sketch flushpage
} stopped clear
menu
showpage
} loop
But ctrl-C just kills the whole interpreter.
Is there a special mode or flag to enable /interrupt errors with GS?
[toc] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-04-26 15:33 -0700 |
| Message-ID | <7be947f0-a0e7-4818-a9b3-94fa2ba5fa15@googlegroups.com> |
| In reply to | #1372 |
On Thursday, April 25, 2013 6:32:39 PM UTC-5, luser- -droog wrote:
> With my Mandelbrot explorer (https://code.google.com/p/xpost/downloads/detail?name=mandel2.ps),
> I'd like to be able to interrupt the drawing and return to the menu if
> the resolution is too high and it's taking too long.
>
> The PLRM, 1ed, says
>
> > interrupt (error)
>
> > processes an external request to interrupt execution of a PostScript
> > program. When the interpreter receives an interrupt request, it executes
> > interrupt as if it were an error (i.e. it looks up the name 'interrupt' in
> > errordict). Execution of interrupt is sandwiched between execution of
> > two objects being interpreted in normal sequence.
>
> > The precise nature of an external interrupt request depends on the en-
> > vironment in which the PostScript interpreter is running. In typical
> > environments, receipt of a control-C character from a serial communi-
> > cation channel gives rise to the interrupt error. This permits a user to
> > explicitly abort a PostScript computation. The default definition of
> > interrupt executes a stop.
>
> I tried wrapping the drawing functions in a stopped context.
>
>
> % The Main Loop
> % - draw the object according to currrent parameters
> % - enter menu loop
> % - showpage
> {
> {
> createtable findmaxmin sketch flushpage
> } stopped clear
> menu
> showpage
> } loop
>
> But ctrl-C just kills the whole interpreter.
>
> Is there a special mode or flag to enable /interrupt errors with GS?
I found something. But I don't know how to make use of it yet.
In psi/interp.c, I found this:
/*
* Invoke the interpreter. If execution completes normally, return 0.
* If an error occurs, the action depends on user_errors as follows:
* user_errors < 0: always return an error code.
* user_errors >= 0: let the PostScript machinery handle all errors.
* (This will eventually result in a fatal error if no 'stopped'
* is active.)
* In case of a quit or a fatal error, also store the exit code.
* Set *perror_object to null or the error object.
*/
static int gs_call_interp(i_ctx_t **, ref *, int, int *, ref *);
int
gs_interpret(i_ctx_t **pi_ctx_p, ref * pref, int user_errors, int *pexit_code,
ref * perror_object)
{
It looks like this `user_errors` parameter controls the behavior I'm talking about (I think). But I haven't traced it back out. I don't know where this function is called.
[toc] | [prev] | [next] | [standalone]
| From | Helge Blischke <h.blischke@acm.org> |
|---|---|
| Date | 2013-04-30 18:35 +0200 |
| Message-ID | <auaa6dFmu6pU1@mid.individual.net> |
| In reply to | #1372 |
luser- -droog wrote:
> With my Mandelbrot explorer
> (https://code.google.com/p/xpost/downloads/detail?name=mandel2.ps), I'd
> like to be able to interrupt the drawing and return to the menu if the
> resolution is too high and it's taking too long.
>
> The PLRM, 1ed, says
>
>> interrupt (error)
>
>> processes an external request to interrupt execution of a PostScript
>> program. When the interpreter receives an interrupt request, it executes
>> interrupt as if it were an error (i.e. it looks up the name 'interrupt'
>> in errordict). Execution of interrupt is sandwiched between execution of
>> two objects being interpreted in normal sequence.
>
>> The precise nature of an external interrupt request depends on the en-
>> vironment in which the PostScript interpreter is running. In typical
>> environments, receipt of a control-C character from a serial communi-
>> cation channel gives rise to the interrupt error. This permits a user to
>> explicitly abort a PostScript computation. The default definition of
>> interrupt executes a stop.
>
>
> I tried wrapping the drawing functions in a stopped context.
>
> % The Main Loop
> % - draw the object according to currrent parameters
> % - enter menu loop
> % - showpage
> {
> {
> createtable findmaxmin sketch flushpage
> } stopped clear
> menu
> showpage
> } loop
>
> But ctrl-C just kills the whole interpreter.
>
> Is there a special mode or flag to enable /interrupt errors with GS?
Looking (not too deeply) into the Ghostscript sources reveals:
it seems that capturing signals like this is mainly restricted to
events associated with the PostScript input (currentfile and friends).
I guess it is not trivial to enhance gs to treat CTRL-C as an interrupt
error without fidling around with the kernel of ghostscript's ps interpreter
ans how it is hooked up to the operating system (to be precise: the OS
abstraction level).
So I'd suggest you file a feature request at bugs.ghostscript.com.
Helge
[toc] | [prev] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-04-30 20:26 -0700 |
| Message-ID | <ba074ad9-1391-4f64-9fc9-8ea7b856ec53@googlegroups.com> |
| In reply to | #1374 |
On Tuesday, April 30, 2013 11:35:23 AM UTC-5, Helge Blischke wrote: > luser- -droog wrote: > > > But ctrl-C just kills the whole interpreter. > > > > > Is there a special mode or flag to enable /interrupt errors with GS? > > > Looking (not too deeply) into the Ghostscript sources reveals: > it seems that capturing signals like this is mainly restricted to > events associated with the PostScript input (currentfile and friends). > I guess it is not trivial to enhance gs to treat CTRL-C as an interrupt > error without fidling around with the kernel of ghostscript's ps interpreter > ans how it is hooked up to the operating system (to be precise: the OS > abstraction level). > > > So I'd suggest you file a feature request at bugs.ghostscript.com. > > > Helge Thanks for the suggestion. Done.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web