-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
fix: do not clean temporary files of the shell which is running. #284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Just the library hasn't been updated in a while.
After a cursory look at the function of this library, it should be fine, but it is indeed a bit old. This library is very new, but it has many dependencies and many unused functions. |
Actually, we can implement it ourselves, and both libraries are a bit complicated. For Windows, we can refer the following code: vfox/internal/shell/windows_process.go Lines 36 to 44 in 2d15fc8
For Unix-like, we can directly use |
package main
import (
"flag"
"os"
"syscall"
)
func main() {
pid := flag.Int("p", 0, "")
flag.Parse()
err := ProcessIsRun(*pid)
if err != nil {
panic(err)
}
}
func ProcessIsRun(pid int) error {
proc, err := os.FindProcess(pid)
if err != nil {
return err
}
defer proc.Release()
return proc.Signal(syscall.Signal(0))
} window does not support Processes created by other users cannot be viewed under Linux. If you only consider cleaning up temporary files generated by the current user, there is no problem in doing so. It is impossible to predict whether this scheme will behave correctly on different platforms. In addition, the above two libraries do not use |
Okay. We can merge this now. |
fix: #283
A running terminal's temporary directory should never be deleted