Skip to content

terminated modern session cause trouble for subsequent session #5730

Closed

Description

@anbj

Please see code below. Short summary:

  • a modern mode session is initiated, w. file download
  • "Oh no, I don't have enough bandwidth for this" -> ^C
  • session is terminated, leaving waste in .gmt/sessions/ causing trouble for subsequent session.

Should there not be a trap for e.g. ^C which triggers cleanup?

$ ls -l .gmt/sessions/
total 0

#make plot - I want @earth_relief_10m
$ gmt grdimage @earth_relief_10m -JM15c -RNO -pdf map
grdimage [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]

grdimage [NOTICE]: Earth Relief at 10x10 arc minutes from Gaussian Cartesian filtering (18 km fullwidth) of SRTM15+V2.1 [Tozer et al., 2019].
grdimage [NOTICE]:   -> Download grid file [3.0M]: earth_relief_10m_p.grd
^C

#^ no way I'm downloading 3.0M! ^C it is.

#use @earth_relief_05m instead, which I already have downloaded
$ gmt grdimage @earth_relief_05m -JM15c -RNO -pdf map
gmt [ERROR]: Cannot run a one-liner modern command within an existing modern mode session

#what?!

#it's the terminated session causing trouble
$ ls .gmt/sessions/
gmt_session.337778

#delete it
$ gmt clear sessions

#works
$ gmt grdimage @earth_relief_05m -JM15c -RNO -pdf map

Tested with bleeding edge.

Activity

  1. added
    bug
    on Sep 6, 2021
  2. self-assigned this
    on Sep 7, 2021
  3. added
    feature request
    on Sep 7, 2021
  4. PaulWessel commented on Sep 7, 2021

    @PaulWessel
    Contributor

    Yes, ideally. There is some relevant history here. Florian Wobbe installed a sig_handler so that when a user hit Ctrl-C it would ask them to hit a second Ctrl-C to really quit. However, we found this interfered in some cases and ended up disabling it (see gmt.c lines 68-71). This was way before modern mode was introduced.

    Now, with modern mode setting up hidden directories for sessions, should a session terminate prematurely due to a Ctrl-C then it seems desirable to remove that directory prior to exiting - this could be done by the sig_action function if we modified it and reenabled things. I see Windows is excluded so either signal is not supported there or they have their own non-posix solution. And as you know, the details tends to be very specific to a unique architecture (chip).

    I have received the same message you get from time to time - usually when debugging and restarting it without letting it complete first.

  5. anbj commented on Sep 7, 2021

    @anbj
    ContributorAuthor

    I see, thanks for explaining, Paul.

    The session-folder gets it's pid appended to the name, e.g. gmt_session.337778.
    Why and how does a new modern mode session care/know about an earlier terminated session?

    PS. I think I made a (bug) post about this issue some years(!) ago. Time flies.

  6. PaulWessel commented on Sep 7, 2021

    @PaulWessel
    Contributor

    The session number is the PID of the parent, i.e., the terminal. So running another modern session in that terminal ends up with the same PID.

  7. anbj commented on Sep 7, 2021

    @anbj
    ContributorAuthor

    Why not do modern sessions in subshells? Wouldn't this problem disappear?

  8. PaulWessel commented on Sep 7, 2021

    @PaulWessel
    Contributor

    Subshells would have different pid and a module cannot know that previous number.

  9. anbj commented on Sep 7, 2021

    @anbj
    ContributorAuthor

    Right. Thanks.

  10. anbj commented on Sep 16, 2021

    @anbj
    ContributorAuthor

    Just want to add this example. It is an error (a "controlled" error) which does not remove the session. Shouldn't it?

    $ gmt grdimage @earth_relief -JEPSG:4326 -RNO -pdf test
    gmt [ERROR]: No projection selected
    gmt [ERROR]: General map projection error
    
    $ gmt grdimage @earth_relief -JEPSG:4326 -RNO -pdf test
    gmt [ERROR]: Cannot run a one-liner modern command within an existing modern mode session
    
    $ ls ~/.gmt/sessions
    gmt_session.3287579
    
  11. anbj commented on Sep 16, 2021

    @anbj
    ContributorAuthor

    One more.

    $ gmt grdimage @earth_relief -J"+proj=merc +ellps=WGS84 +units=m" -pdf test
    gmt [ERROR]: Libcurl Error: HTTP response code said error
    gmt [WARNING]: You can turn remote file download off by setting GMT_DATA_UPDATE_INTERVAL to "off"
    gmt [ERROR]: Cannot request automatic remote grid resolution without -R -J settings [@earth_relief]
    
    $ gmt grdimage @earth_relief_10m -J"+proj=merc +ellps=WGS84 +units=m" -pdf test
    gmt [ERROR]: Cannot run a one-liner modern command within an existing modern mode session
    
    $
    
  12. added this to the milestone on Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions