-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for support of different platforms
- Loading branch information
Showing
8 changed files
with
112 additions
and
93 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!plan9,!solaris | ||
|
||
package daemon | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func (d *Context) reborn() (child *os.Process, err error) { | ||
return nil, errNotSupported | ||
} | ||
|
||
func (d *Context) search() (daemon *os.Process, err error) { | ||
return nil, errNotSupported | ||
} | ||
|
||
func (d *Context) release() (err error) { | ||
return nil, errNotSupported | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!plan9,!solaris | ||
|
||
package daemon | ||
|
||
func lockFile(fd uintptr) error { | ||
return errNotSupported | ||
} | ||
|
||
func unlockFile(fd uintptr) error { | ||
return errNotSupported | ||
} | ||
|
||
func getFdName(fd uintptr) (name string, err error) { | ||
return "", errNotSupported | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// +build darwin dragonfly freebsd linux netbsd openbsd plan9 solaris | ||
|
||
package daemon | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func lockFile(fd uintptr) error { | ||
err := syscall.Flock(int(fd), syscall.LOCK_EX|syscall.LOCK_NB) | ||
if err == syscall.EWOULDBLOCK { | ||
err = ErrWouldBlock | ||
} | ||
return err | ||
} | ||
|
||
func unlockFile(fd uintptr) error { | ||
err := syscall.Flock(int(fd), syscall.LOCK_UN) | ||
if err == syscall.EWOULDBLOCK { | ||
err = ErrWouldBlock | ||
} | ||
return err | ||
} | ||
|
||
func getFdName(fd uintptr) (name string, err error) { | ||
// TODO(yar): This way does not work on darwin, use fcntl | ||
path := fmt.Sprintf("/proc/self/fd/%d", int(fd)) | ||
|
||
var ( | ||
fi os.FileInfo | ||
n int | ||
) | ||
if fi, err = os.Lstat(path); err != nil { | ||
return | ||
} | ||
buf := make([]byte, fi.Size()+1) | ||
|
||
if n, err = syscall.Readlink(path, buf); err == nil { | ||
name = string(buf[:n]) | ||
} | ||
return | ||
} |
File renamed without changes.