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

Exit when stdin closes #23

Merged
merged 1 commit into from Aug 9, 2021
Merged

Conversation

mhanberg
Copy link
Contributor

This is useful for long running processes that are started by other tools like web frameworks.

These two lines were taken from the postcss-cli.

This is useful for long running processes that are started by other tools
like web frameworks.

These two lines were taken from the [postcss-cli](https://github.com/postcss/postcss-cli/blob/4be419d4dab07b8982b4bdc04456c02880dbf667/index.js#L55..L56).
@bcomnes
Copy link
Owner

bcomnes commented Aug 5, 2021

My apologies, I totally missed this.

Can you explain the problem thats going that this solves?

@mhanberg
Copy link
Contributor Author

mhanberg commented Aug 9, 2021

No worries.

To quote someone smarter than me.

Most command line tools (cat, fsevents, etc) and JS CLI watchers (postcss,
webpack, etc) listen to stdin and abort when the stdin is closed (for example,
by sending Ctrl+D). This is important because there is no guarantee the
process who invokes [cpx] will terminate it, but it is guaranteed the stdin
will be closed once the parent dies.

Basically, when I start cpx as a "watcher" with Elixir/Erlang, there is a zombie node process of cpx that persists after the Elixir/Erlang VM exits.

@bcomnes
Copy link
Owner

bcomnes commented Aug 9, 2021

Cool, sounds good. I'll run some tests locally to make sure everything is still working as expected.

@bcomnes bcomnes merged commit ae1f9b7 into bcomnes:master Aug 9, 2021
@bcomnes
Copy link
Owner

bcomnes commented Aug 9, 2021

Seems to work fine here. I'll do a release.

@bcomnes
Copy link
Owner

bcomnes commented Aug 9, 2021

cpx2@3.0.1

@meteorlxy
Copy link

meteorlxy commented Aug 13, 2021

This change somehow breaks my usage with lerna.

You can take this project as a reproduction:

https://github.com/vuepress/vuepress-next/blob/main/package.json

yarn
yarn copy-watch

The yarn copy-watch command works properly with cpx2@3.0.0, but it will exit immediately with cpx2@3.0.1

@bcomnes
Copy link
Owner

bcomnes commented Aug 13, 2021

@meteorlxy Sorry about that. Pin to 3.0.0 while we figure this out. @mhanberg any ideas?

@bcomnes
Copy link
Owner

bcomnes commented Aug 13, 2021

I'm going to revert the change until we can clarify the issue being solved here more. @mhanberg can you send me a small gist or something with a package.json and whatever scripts you were using that sets up the zombie process issue you ran into?

bcomnes added a commit that referenced this pull request Aug 13, 2021
This reverts commit ae1f9b7, reversing
changes made to 7fb869b.

See #23 (comment)

# Conflicts:
#	bin/main.js
@bcomnes
Copy link
Owner

bcomnes commented Aug 13, 2021

Reverted: cpx2@3.0.2

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

Successfully merging this pull request may close these issues.

None yet

3 participants