Skip to content

Use syscall.Exec instead of cmd.Run in non-windows environment#77

Open
Songmu wants to merge 1 commit into
joho:mainfrom
Songmu:exec
Open

Use syscall.Exec instead of cmd.Run in non-windows environment#77
Songmu wants to merge 1 commit into
joho:mainfrom
Songmu:exec

Conversation

@Songmu

@Songmu Songmu commented Jun 17, 2019

Copy link
Copy Markdown

Using syscall.Exec makes the process tree simpler and is useful when you want the child process to handle the signal.

For example, the direnv program internally uses syscall.Exec.

https://github.com/direnv/direnv/blob/5b8f7d0ade4248e04899015e8628408b6f4becf3/cmd_exec.go#L67

How about it?

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
@nicholasngai

nicholasngai commented Jan 30, 2026

Copy link
Copy Markdown

@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!

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.

2 participants