Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Nov 5, 2019
2 parents 148dd00 + aa4ec8f commit 1e58ece
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,8 @@ public int getOwnerIdOf(File file) {
try {
// The binding for 'stat' is very platform dependant. To avoid the complexity of binding the correct method,
// stat is called as a separate command. This is less efficient but more portable.
Process process = Runtime.getRuntime().exec("stat -c=%u " + file.getAbsolutePath());
String statUserSwitch = Platform.isMac() ? "-f" : "-c";
Process process = Runtime.getRuntime().exec("stat " + statUserSwitch + " %u " + file.getAbsolutePath());
int attempts = this.attempts;
boolean exited = false;
String line = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")).readLine();
Expand All @@ -2043,7 +2044,7 @@ public int getOwnerIdOf(File file) {
process.destroy();
throw new IllegalStateException("Command for stat did not exit in time");
}
return Integer.parseInt(line.substring(1));
return Integer.parseInt(line);
} catch (IOException exception) {
throw new IllegalStateException("Unable to execute stat command", exception);
}
Expand Down Expand Up @@ -2091,7 +2092,8 @@ private void notifySemaphore(File directory, String name, int count, short opera
try {
library.semop(semaphore, target, 1);
} catch (LastErrorException exception) {
if (acceptUnavailable && Native.getLastError() == PosixLibrary.EAGAIN) {
if (acceptUnavailable && (Native.getLastError() == PosixLibrary.EAGAIN
|| Native.getLastError() == PosixLibrary.EDEADLK)) {
break;
} else {
throw exception;
Expand Down Expand Up @@ -2123,6 +2125,11 @@ protected interface PosixLibrary extends Library {
*/
int EAGAIN = 11;

/**
* Indicates a dead lock on a resource.
*/
int EDEADLK = 35;

/**
* Indicates that a semaphore's operations should be undone at process shutdown.
*/
Expand Down

0 comments on commit 1e58ece

Please sign in to comment.