npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

run-in-separate-pgrp

v1.2.1

Published

Launch a console command in a newly created foreground process group

Downloads

1,785

Readme

CI run

run-in-separate-pgrp: launch a console command in a newly created foreground process group

This wrapper tool launches an arbitrary command (and all its future child processes) in a newly created process group. The new process group also becomes foreground (interactive in terminal) if you ran the tool in an interactive session.

Usage

run-in-separate-pgrp
  [--forward-signals-to-group | --forward-signals-to-child]
  [--print-signals]
  command [arg ...]

Use Case 1: Limit Ctrl-C Impact

Use the tool if you want to limit the scope of Ctrl-C SIGINT propagation to only the hierarchy of that new process group.

Motivation: terminals send SIGINT to ALL processes of a foreground process group when Ctrl-C is pressed (not only to one process), which may kill some intermediate parent processes like yarn. As an example, the tool can be used to let interactive psql run in a yarn script (without the tool, yarn dies on SIGINT, which effectively closes STDIN for psql).

With the tool, you can use Ctrl-C when running yarn psql:

Without the tool, pressing Ctrl-C kills yarn and thus kills psql on stdin EOF:

See details here:

  • https://www.postgresql.org/message-id/flat/271520.1713052173%40sss.pgh.pa.us#6ebc31cdb0365b0de9e0a2e7e5cb2268
  • https://www.cons.org/cracauer/sigint.html

Use Case 2: Fanout Incoming Signals to All Processes in the New Group

If --forward-signals-to-group flag is passed, and the tool's process ID receives some signal, this signal is forwarded to all children processes subtree (in fact, to the processes of the new group). This is useful in e.g. GitHub Actions which send a SIGINT to the currently running shell process ONLY. Shells ignore that SIGINT, so the running jobs continue running until they are cruelly killed by the action runner in ~10 seconds.

Alternatively, when --forward-signals-to-child is passed, the tool forwards the signals to the command's process only (no fanout). This is less useful of course.

See details here:

  • https://github.com/ringerc/github-actions-signal-handling-demo

Installation

You can download the tool file run-in-separate-pgrp and put it anywhere you want (it's a stand-alone Perl script with no dependencies):

wget https://raw.githubusercontent.com/dimikot/run-in-separate-pgrp/main/run-in-separate-pgrp
chmod +x run-in-separate-pgrp

Alternatively, you can install it as a Node module to be available in your PATH:

npm install run-in-separate-pgrp
yarn add run-in-separate-pgrp
pnpm install run-in-separate-pgrp