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

There is no way to add a shutdown hook #12170

Closed
DartBot opened this issue Aug 1, 2013 · 9 comments
Closed

There is no way to add a shutdown hook #12170

DartBot opened this issue Aug 1, 2013 · 9 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-l library-isolate type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Aug 1, 2013

This issue was originally filed by googlegroups...@kaioa.com


Java got addShutdownHook, Ruby got at_exit, Python got an atexit module, and Node got process.on('SIGTERM', ...).

Dart doesn't seem to offer anything comparable.

Relevant SO thread:

http://stackoverflow.com/questions/11001071/shutdown-hook-in-dart

@dgrove
Copy link
Contributor

dgrove commented Aug 1, 2013

Added Area-Library, Library-Isolate, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Aug 23, 2013

Removed Type-Defect label.
Added Type-Enhancement label.

@DartBot
Copy link
Author

DartBot commented Aug 16, 2014

This comment was originally written by @kaendfinger


This can be marked as fixed I think, because we can add hooks for SIGTERM.

@DartBot
Copy link
Author

DartBot commented Aug 16, 2014

This comment was originally written by @zoechi


Does this work on all platforms?
I haven't used it myself but there were complaints in the forum after this was implemented (several months ago though) that there is no single hook that works on all platforms.

@DartBot
Copy link
Author

DartBot commented Aug 17, 2014

This comment was originally written by googlegroups...@kaioa.com


According to the docs, most of those process signals are not available on Windows:

https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-io.ProcessSignal#id_watch

I just tried it myself. This example works with Linux, but not with Windows:

    import 'dart:io';
    
    void main() {
      ProcessSignal.SIGTERM.watch().listen((_) {
        print('SIGTERM');
      });
    }

On Windows, it bombs with:

    Uncaught Error: SignalException: Failed to listen for SIGTERM

@azenla
Copy link
Contributor

azenla commented Feb 12, 2015

Note: calling exit(0) does not call SIGTERM listeners. I think that this decision should be re-evaluated.

@DartBot
Copy link
Author

DartBot commented Apr 20, 2015

This comment was originally written by @kaendfinger


Whatever node does to fake SIGTERM or something for it's exit listener, that's what we need to do.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate labels Apr 20, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@lrhn lrhn added core-m and removed core-m labels Aug 11, 2017
@floitschG
Copy link
Contributor

This could be solved by an exit-callback for the current isolate: #21999

@floitschG floitschG removed the core-m label Aug 28, 2017
@natebosch
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-l library-isolate type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants