File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 3030 namedPipe = flag .String ("winssh" , "" , "Named pipe for use with Win32 OpenSSH" )
3131 verbose = flag .Bool ("verbose" , false , "Enable verbose logging" )
3232 systrayFlag = flag .Bool ("systray" , false , "Enable systray integration" )
33+ force = flag .Bool ("force" , false , "Force socket usage (unlink existing socket)" )
3334)
3435
3536const (
@@ -209,6 +210,17 @@ func main() {
209210 }()
210211
211212 if * unixSocket != "" {
213+ if * force {
214+ // If the socket file already exists then unlink it
215+ _ , err := os .Stat (* unixSocket )
216+ if err == nil || ! os .IsNotExist (err ) {
217+ err = syscall .Unlink (* unixSocket )
218+ if err != nil {
219+ log .Fatalf ("Failed to unlink socket %s, error '%s'\n " , * unixSocket , err )
220+ }
221+ }
222+ }
223+
212224 unix , err = net .Listen ("unix" , * unixSocket )
213225 if err != nil {
214226 log .Fatalf ("Could not open socket %s, error '%s'\n " , * unixSocket , err )
You can’t perform that action at this time.
0 commit comments