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

Deno.Process close()/status()/kill() #6373

Closed
aricart opened this issue Jun 19, 2020 · 5 comments
Closed

Deno.Process close()/status()/kill() #6373

aricart opened this issue Jun 19, 2020 · 5 comments
Labels
docs public API related to "Deno" namespace in JS stale

Comments

@aricart
Copy link
Contributor

aricart commented Jun 19, 2020

Deno.Process probably needs a bit more documentation:

  • if close() is called, status() will throw an exception with a bad resource id.
  • kill() followed by a status() works fine
  • I would expect status() to always work regardless of how the process was terminated.

I would have expected status() to resolve its promise regardless of how the Process is closed/kill or otherwise.

My use of Deno.run() is running a server that I can use for tests. So this creates interesting because if things don't close properly, the tests will fail with resource leaks (love that).

@bartlomieju bartlomieju added docs public API related to "Deno" namespace in JS labels Jul 14, 2020
@caseyhoward
Copy link

caseyhoward commented Aug 7, 2020

I was also wondering what close() did since there is no documentation. I want to kill a process after a specified timeout. Do I use close() or kill()?

I just tried close() and it appears to do nothing so I tried kill() which works but then I can see terminal input after the process exits and I have to run reset.

@ry
Copy link
Member

ry commented Aug 7, 2020

Close releases Deno’s memory associated with the process. So the subprocess will continue to run. Kill actually sends a signal to the subprocess.

@aricart
Copy link
Contributor Author

aricart commented Aug 8, 2020

@ry one thing with close is that it doesn't address closing any of the file descriptors - for example, on some utility code I have I had to:

  async stop(): Promise<void> {
    if (!this.stopped) {
      this.stopped = true;
      this.process.stderr?.close();
      this.process.kill(Deno.Signal.SIGKILL);
      this.process.close();
    }
    await this.done;
  }

The unexpected thing is that stderr had to be closed specifically - even though the close - which is owning it is getting called.

@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2021
@stale stale bot closed this as completed Jan 13, 2021
@martin-braun
Copy link

Close releases Deno’s memory associated with the process. So the subprocess will continue to run. Kill actually sends a signal to the subprocess.

Thanks for the explanation. Is using close() mandatory, though? Shouldn't Deno release memory associated with the process on the end of the scope, automatically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs public API related to "Deno" namespace in JS stale
Projects
None yet
Development

No branches or pull requests

5 participants