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

Add a terminate/kill method to core::run::Program (or make destroy kill the process) #5632

Closed
Dretch opened this issue Mar 30, 2013 · 1 comment

Comments

@Dretch
Copy link
Contributor

Dretch commented Mar 30, 2013

I would like to be able to forcibly terminate a spawned process, like you can in Python (http://docs.python.org/2/library/subprocess.html#subprocess.Popen.terminate) or Java (http://docs.oracle.com/javase/7/docs/api/java/lang/Process.html#destroy%28%29).

There is currently a destroy method in the core::Program trait that closes stdin, waits for the process to finish and then closes stderr/stdout.

I am suggesting that either a new method be added to Program that forcibly kills the spawned process, or that the behaviour of destroy be changed to act in that way.

I think it would be better if the behaviour of destroy was changed because:

  • I think that forcible termination is an intuitive behaviour for the name destroy.
  • I don't think anybody is actually using the destroy method currently because, due to a bug in core::run, a segfault will occur due to a double fclose if you actually call it.

Are there any objections to this? If not I can send a pull request with code/tests.

Dretch pushed a commit to Dretch/rust that referenced this issue Apr 6, 2013
forcibly terminate the program (as suggested in issue rust-lang#5632)
bors added a commit that referenced this issue Apr 13, 2013
As proposed in issue #5632.

I added some new stuff to libc - hopefully correctly. I only added a single signal constant (SIGKILL) because adding more seems complicated by differences between platforms - and since it is not required for issue #5632 then I figure that I can use a further pull request to flesh out the SIG* constants more.
@Dretch
Copy link
Contributor Author

Dretch commented Apr 13, 2013

The proposed change has now been integrated, so this can be considered fixed.

@Dretch Dretch closed this as completed Apr 13, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant