gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
277 stars 61 forks source link

Warning: UNIT keyword to SPAWN may not yet be fully implemented (proceeding) #1910

Open mzechmeister opened 1 week ago

mzechmeister commented 1 week ago

I would like to switch to gdl. However, communication with the shell is essential. E.g. I wrote wrappers for gnuplot and ds9.

Yet, a simple spawn-command on Linux yields

GDL> spawn, 'gnuplot', unit=unit
% Warning: UNIT keyword to SPAWN may not yet be fully implemented (proceeding)

and the script console starts hanging.

I'm a bit surprised that after years this is not still implemented. When will it be implemented?

GillesDuvert commented 1 week ago

@mzechmeister according to the internal documentation the UNIT keyword has been programmed by Greg Huey in ... 2002. I happen to have ds9 on my machine and spawn, 'ds9', unit=unit opens a ds9 console.

GDL> spawn, 'ds9  p85362f1.fits', unit=unit
% Warning: UNIT keyword to SPAWN may not yet be fully implemented (proceeding)

However

GDL> ds9, dindgen(10,10), port='gdl', obj='10x10'
XPA$ERROR no 'xpaget' access points match template: gdl
mzechmeister commented 4 days ago

Putting the following snippet line by line into the command line, it works in idl, but hangs/blocks in gdl:

spawn, 'ds9 -title gdl &'

spawn, "xpaset gdl array -'[xdim=10,ydim=10,bitpix=-64]' ", unit=unit
writeu, unit, dindgen(10,12)
close, unit

So sending data directly via piping and communication viaunit seems not to work in gdl.

mzechmeister commented 4 days ago

Another issue seems with EXIT_STATUS. I found it from an xpaget xpans command and minimise it to echo A

spawn, 'echo A', result, err, EXIT_STATUS=status

print, 'result:', result
print, 'err:', err
print, 'status:', status

In idl the output is:

result: A
err:
status:           0

In gdl

result:A
err:
status:    -6824616

(BTW, from the example print, 'A', ['B'] is outputted with space in idl, but without in gdl.)

Similar, for spawn, '(exit 1)', result, err, EXIT_STATUS=status, idl yields properly status=1, while gdl yields again -6824616.

alaingdl commented 4 days ago

Thanks you @mzechmeister for your feedback

The case spawn, 'echo A', result, err, EXIT_STATUS=status & print, status is clearly a regression which appeared in the code after July 25 (Version v1.0.6-16-gc154de16 was OK) The regression was not detected because we don't have tests covering well SPAWN :disappointed:

The same for spawn, '(exit 1)', result, err, EXIT_STATUS=status

Unfortunately, NO line in basic_pro.cpp which contains the core of SPAWN has been change between July & now ...

alaingdl commented 4 days ago

I take some time to test, and yes, basic exchange with DS9 is OK (SPAWN, 'ds9', unit=unit,/noshell then closing ds9 then printing unit) But it is not working fine for GNUPLOT ... but the functionalities you @mzechmeister have in gplot.pro are very smart and interesting !

alaingdl commented 4 days ago

I am clearly not an expert but it seems the problem for EXIT_STATUS come from the lines close to 2145 in basic_pro.cpp

       // wait until child terminates
        int status;
        pid_t wpid = wait(&status);

I don't know why it was OK before. From the doc, it seems the way we manage status is not what we should do !