Giter Club home page Giter Club logo

Comments (14)

EnzoMartin avatar EnzoMartin commented on May 26, 2024 1

🐒

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024 1

Yep, for Windows anyways. Don't have OSX/Linux to test with

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

Thanks for reporting this. Would you be willing to makeapullrequest.com to fix it?

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

Hm, maybe, I'm not quite sure how best to handle it. Quick untested idea:

const signals = ['SIGTERM', 'SIGINT', 'SIGPIPE', 'SIGBREAK', 'SIGWINCH'];

function crossEnv(args) {
  // Stuff
  signals.forEach((signal) => {
    process.on(signal, (...eventArgs) => proc.emit.apply(proc, eventArgs));
  });
}

Though that won't proxy other events and needs to be updated if Node adds more signals

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

I'm fine with that approach. Is there any internal module we can use that has that list of signals so we don't have to update in the future?

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

If not, I'm good hardcoding it and keeping it updated.

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

There isn't a built-in event list that I can see no. However, I find it unlikely that they'll add signals, since it's just following the standard POSIX signaling spec

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

Another option would be to use something like https://github.com/asyncly/EventEmitter2 and wrap process, or, injecting process.emit with a function call to patch the event through

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

you're suggesting using onAny from EventEmitter2? Seems interesting. Though I think I actually like monkey-patching process.emit a little better.

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

Yes, though I think using EventEmitter2 is a bit overkill for this

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

Agreed. Let's monkey-patch process.emit 👍

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

I'll get a PR up later this week, need to fix the tests

from cross-env.

EnzoMartin avatar EnzoMartin commented on May 26, 2024

So while testing various things on how best to do this (also wanted to see about proxy'ing all events) I've noticed that the current version of the module actually leaves zombie processes behind, as the child process isn't killed when the parent process is killed (at least on Windows).

Seems it's because Windows sends a SIGINT signal on kill usually, rather than SIGTERM

Gonna PR for adding all the kill signals then, then see how to handle all events.

The way the tests are set up makes it a bit tricky to test, especially with the way Node handles exit events, so I'm not sure I can get to 100% tested, but we'll see..

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

I've noticed that the current version of the module actually leaves zombie processes behind

So this is resolved as part of your merged PR too right?

from cross-env.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.