Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mzechmeister opened this issue Nov 11, 2024 · 8 comments

Comments

@mzechmeister
Copy link

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
Copy link
Contributor

@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 referenced this issue in mzechmeister/idl Nov 17, 2024
@mzechmeister
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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 😞

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
Copy link
Contributor

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
Copy link
Contributor

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 !

@GillesDuvert
Copy link
Contributor

#1917 solves for this problem. Thanks to @jkohnert for finding the problem introduced when adding the code for IDL_IDLbridge.

Please test and reopen a new issue if necessary.
Thanks for using GDL!

for the record, I understand that at least two GDL programs may have similar use as ds9: atvand plotman (part of NASA's SSW package).

@mzechmeister
Copy link
Author

One can still not communicate via the unit keyword. Here an even more basic example

IDL> spawn, 'bc 1>&2', unit=unit
IDL> printf, unit, '1+1'
IDL> 2

Since stdout seems to be captured, the example redirects it to stderr.

However, in gdl it just prints in the input

GDL> spawn, 'bc 1>&2', unit=unit  
printf, unit,'1+1'
% Warning: UNIT keyword to SPAWN may not yet be fully implemented (proceeding)
1+1

Moreover, the interactive console behaves strange after spawning. When typing one has to hit a character several times until it appears.

I haven't tried yet a birectional pipe with readu (https://www.nv5geospatialsoftware.com/docs/UsingSpawnAndPipes.html). This would be next.

I would like to reopen the issue, but I didn't have the button (permissions?) for that.

@GillesDuvert GillesDuvert reopened this Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants