{"id":16747944,"url":"https://github.com/amake/npmsigtest","last_synced_at":"2026-02-06T03:32:41.063Z","repository":{"id":181144586,"uuid":"666289042","full_name":"amake/npmsigtest","owner":"amake","description":"Test signal handling with npm as PID 1","archived":false,"fork":false,"pushed_at":"2023-07-14T11:12:23.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T21:29:42.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amake.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-14T06:39:25.000Z","updated_at":"2023-07-14T06:39:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ce8da93-391d-4984-a860-a84d9318b500","html_url":"https://github.com/amake/npmsigtest","commit_stats":null,"previous_names":["amake/npmsigtest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amake/npmsigtest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amake%2Fnpmsigtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amake%2Fnpmsigtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amake%2Fnpmsigtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amake%2Fnpmsigtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amake","download_url":"https://codeload.github.com/amake/npmsigtest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amake%2Fnpmsigtest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29148179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T02:11:19.666Z","updated_at":"2026-02-06T03:32:41.048Z","avatar_url":"https://github.com/amake.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Signal handling when using npm as PID 1\n\nThere's various information warning against using npm as PID 1 in a container,\n[though some of it is\nold](https://help.heroku.com/ROG3H81R/why-does-sigterm-handling-not-work-correctly-in-nodejs-with-npm).\n\nIn particular there are claims that npm will not propagate signals to child\nprocesses, preventing clean shutdowns e.g. via SIGTERM. However [this is no\nlonger true](https://github.com/npm/npm/pull/10868).\n\nI noted that npm in some cases seems to respond to SIGTERM but does so by\nimmediately killing its children, preventing any application SIGTERM handlers\nfrom running to completion. This repo contains the tests that allowed me to come\nto the following conclusion:\n\n\u003e npm as PID 1 allows safe SIGTERM handling *when the underlying shell it\n\u003e executes scripts with* is a \"well-behaved one\". **In particular, dash, the\n\u003e default on Debian 6+, is *not* well-behaved.**\n\u003e\n\u003e Shells observed to be well-behaved include zsh, bash, and busybox (default on\n\u003e Alpine).\n\u003e\n\u003e Thus if your base image is\n\u003e [`node:\u003cversion\u003e-slim`](https://github.com/nodejs/docker-node#nodeslim)\n\u003e (Debian) and you need well-behaved SIGTERM handling, then you must install\n\u003e e.g. bash and configure npm to use it:\n\u003e\n\u003e ```\n\u003e npm config set script-shell=bash\n\u003e ```\n\u003e\n\u003e Note that\n\u003e [`node:\u003cversion\u003e-alpine`](https://github.com/nodejs/docker-node#nodealpine)\n\u003e does not suffer from this issue because its default shell is Busybox.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famake%2Fnpmsigtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famake%2Fnpmsigtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famake%2Fnpmsigtest/lists"}