Created
January 5, 2023 02:04
-
-
Save dstyle0210/cab187db662aaa4012240a940873112f to your computer and use it in GitHub Desktop.
[node] pid을 이용해서 node로 발생시킨 자식프로세스 닫기(연결끊기)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 참고 : https://velog.io/@dev2820/nodejs%EC%9D%98-%EC%9E%90%EC%8B%9D%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4 | |
| const { spawn } = require("child_process"); | |
| const makeChildProcess = () => { | |
| const child = spawn("커멘드",{ | |
| detached:true, | |
| stdio:"ignore" | |
| }); | |
| console.log( child.pid ); // (1) 나중에 닫을려고 일단 꺼내보기 | |
| child.unref(); // 자식프로세스와 연결끊기(부모프로세스 종료) | |
| } | |
| const closeChildProcess = () => { | |
| process.kill(pid); // (1) 에서 본 pid 입력해서 넣으면 동작 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment