Giter VIP home page Giter VIP logo

child_process_experiments's Introduction

NodeJS child process experiments

  • spawning child (and sub) processes
  • blocking processes (stream + timers)
  • sending signals

Keeping process open:

  • pipes for stdin/stdout+stderr are established between the parent Node.js process and the spawned child
  • holding process/shell open:
    • timers + stream (of data, via TCP sockets) hold it
    • spawn(process.execPath, args) -> holds (stream)
    • process.stdout.on('data') -> holds (stream)
      • same applies to parent or child process
    • setTimeout(() => { /* code */ }, 1000) - holds (timer)
    • process.on('SIGINT') -> doesnt hold (not a stream, an event)
  • WHY:
    • child process waits to read all of its input
    • the child will not continue until the stream has been closed via end() or kill().
    • process.stdin.end() OR process.kill('SIGINT')
    • can pass kill event down stack i.e. parent -> child -> baby
  • 'EXIT' event - emitted after the child process ends
    • IF nothing holding process will always run at end of script
    • ELSE signal could manually have exited it, will have signal.

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.