Use syscall.Exec instead of cmd.Run in non-windows environment#77
Open
Songmu wants to merge 1 commit into
Open
Use syscall.Exec instead of cmd.Run in non-windows environment#77Songmu wants to merge 1 commit into
Songmu wants to merge 1 commit into
Conversation
hoshsadiq
added a commit
to hoshsadiq/godotenv
that referenced
this pull request
Nov 23, 2021
Using exec is better in this case as it makes the process tree simpler, and allows the child's signals to be handled by the caller. In addition the `Exec` function has been removed as it's not really great as a library function. Users should manually call the `Load` function and run `exec.Command` or `syscall.Exec` appropriately. In the future we probably want to handle signals for Windows anyway. This is based on joho/godotenv#77 and also addresses the following PRs in upstream: - joho/godotenv#119
|
@joho Any chance we could look at getting this merged in? Would be helpful to have to avoid some issues when dealing with commands that connect to the TTY/deal with signal handling! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using
syscall.Execmakes the process tree simpler and is useful when you want the child process to handle the signal.For example, the
direnvprogram internally usessyscall.Exec.https://github.com/direnv/direnv/blob/5b8f7d0ade4248e04899015e8628408b6f4becf3/cmd_exec.go#L67
How about it?