|
From: sfeam <sf...@us...> - 2017-02-04 17:52:10
|
On Saturday, 04 February 2017 09:38:31 AM pl...@pi... wrote:
> On 04/02/17 04:14, sfeam wrote:
> > On Saturday, 04 February 2017 01:17:25 AM : pl...@pi... wrote:
> >> Hi,
> >>
> >> I am calling gnuplot as a child process and need to conditionally return
> >> a non zero error code in some circumstances. From a quick search it
> >> seems that this is not possible, It always returns zero: yet that seems
> >> a little surprising.
> >>
> >> perl -e 'system("gnuplot -e \"exit 1;\""); print "$?\n"'
> >>
> >> The only way I can get a non zero result is if there is a parsing error
> >> in the gnuplot commands.
> >>
> >> I am using gnuplot to display real time data on a server and it would be
> >> good to be able to do some basic error trapping, not least for
> >> debugging. Is there a way to do this?
> >
> > Correct. There is no way to control the gnuplot exit value.
> >
> >
>
> Thanks for the confirmation, Ethan.
>
> Would this be a worthwhile feature to add?
Sure. But I have no idea how we would do it.
Adding a command "exit <status>" would not help so far as I can see,
because in order to execute that command the program must be
in a non-error state. So the only code it makes sense to emit is 0.
If there is a serious error like segfault or divide-by-zero the
program exits via the system fault-handling and gnuplot's normal
exit routine is not invoked. If there is a non-fatal error
(read past end-of-file, say) gnuplot handles this internally and
by the time it is ready to parse a new command like "exit" the
error state no longer exists.
What sort of error do you imagine reporting?
Ethan
> I'm thinking of something
> like the awk exit which allows an optional integer argument to return.
>
> if ( ! happy ) { print "not happy" ; exit 1; )
>
> gnuplot is an excellent tool for plotting real time data on embedded
> devices to provide real time graphic output but obviously the
> possibility to exit with an error condition can be helpful, firstly in
> debugging and also trapping possible error conditions with a meaningful
> response should they happen.
>
> The current behaviour is just jexit 0 , for backwards compat, some
> thought would need to be given to current non zero return in case of a
> syntax error in a gnuplot script but this does not seem to raise any
> conflict for those trapping current behaviour.
>
> Peter.
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> gnuplot-beta mailing list
> gnu...@li...
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
|