Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When killing a process, ensure it was killed #105

Closed
sindresorhus opened this issue Aug 5, 2017 · 3 comments · Fixed by #208
Closed

When killing a process, ensure it was killed #105

sindresorhus opened this issue Aug 5, 2017 · 3 comments · Fixed by #208

Comments

@sindresorhus
Copy link
Owner

When a user does child.kill() (NOT when child.kill('SIGKILL')), after some timeout (How long?), we should check if the process was actually killed with process.kill(0) and do process.kill('SIGKILL') if not.

@Ncf16
Copy link

Ncf16 commented Jul 9, 2018

Hello,

I am trying to fix this issue, my idea was to alter the handler removeExitHandler

// The handler in question
removeExitHandler = onExit(() => {
       // Added instruction
	setCheckKilled(spawned);
	spawned.kill();
	});

function setCheckKilled(spawned) {
		setTimeout(() => {
			checkDeath(spawned.pid, spawned.ppid, spawned.uid);
		}, TIME_TO_CHECK_KILL);

	}

function checkDeath(pid, ppid, uid) {
		console.log(pid + " " + ppid + " " + uid)
		findProcess.find("pid", pid).then((list) => compareFields({
			"ppid": ppid,
			"uid": uid
		}, list));
	}

I was thinking of using the package find-process. So that I could get the information related to the process to compare to what I have stored. However I have come across a problem, with the information returned by the find-process package I do no have access to the process itself. That lead me to have a better look at the issue and raised a question.
In this context what is the difference between child and process?

@sindresorhus
Copy link
Owner Author

I was thinking of using the package find-process.

That package is way too bloated and not even needed for this purpose.

I do no have access to the process itself

I don't understand what you're trying to do.

In this context what is the difference between child and process?

https://www.google.co.th/search?q="child+process"+vs+process

@sindresorhus
Copy link
Owner Author

I have already explained the solution in the issue text:

we should check if the process was actually killed with process.kill(0) and do process.kill('SIGKILL') if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants