if (WIFEXITED(status.value)) { exitValue = WEXITSTATUS(status.value); } else if (WIFSIGNALED(status.value)) { exitValue = WTERMSIG(status.value); } else if (WIFSTOPPED(status.value)) { exitValue = WSTOPSIG(status.value); } else { throw new AssertionError("unexpected status from waitpid: " + status.value);
/** * Converts the stashed function name and errno value to a human-readable string. * We do this here rather than in the constructor so that callers only pay for * this if they need it. */ @Override public String getMessage() { String errnoName = OsConstants.errnoName(errno); if (errnoName == null) { errnoName = "errno " + errno; } String description = Libcore.os.strerror(errno); return functionName + " failed: " + errnoName + " (" + description + ")"; }
/** * Indicates if this file represents a <em>directory</em> on the * underlying file system. * * @return {@code true} if this file is a directory, {@code false} * otherwise. */ public boolean isDirectory() { try { return S_ISDIR(Libcore.os.stat(path).st_mode); } catch (ErrnoException errnoException) { // The RI returns false on error. (Even for errors like EACCES or ELOOP.) return false; } }
public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); } public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); }
/** * Indicates if this file represents a <em>file</em> on the underlying * file system. * * @return {@code true} if this file is a file, {@code false} otherwise. */ public boolean isFile() { try { return S_ISREG(Libcore.os.stat(path).st_mode); } catch (ErrnoException errnoException) { // The RI returns false on error. (Even for errors like EACCES or ELOOP.) return false; } }
public static int WSTOPSIG(int status) { return WEXITSTATUS(status); } public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
@Override public void close(FileDescriptor fd) throws ErrnoException { try { if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) { if (isLingerSocket(fd)) { // If the fd is a socket with SO_LINGER set, we might block indefinitely. // We allow non-linger sockets so that apps can close their network // connections in methods like onDestroy which will run on the UI thread. BlockGuard.getThreadPolicy().onNetwork(); } untagSocket(fd); } } catch (ErrnoException ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily // a socket at all. } os.close(fd); }
public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); } public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }
if (S_ISREG(Libcore.os.fstat(fd).st_mode) || ftruncateException.errno != EINVAL) { throw ftruncateException.rethrowAsIOException();
public static int WSTOPSIG(int status) { return WEXITSTATUS(status); } public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
@Override public void close(FileDescriptor fd) throws ErrnoException { try { if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) { if (isLingerSocket(fd)) { // If the fd is a socket with SO_LINGER set, we might block indefinitely. // We allow non-linger sockets so that apps can close their network // connections in methods like onDestroy which will run on the UI thread. BlockGuard.getThreadPolicy().onNetwork(); } untagSocket(fd); } } catch (ErrnoException ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily // a socket at all. } os.close(fd); }
if (WIFEXITED(status.value)) { exitValue = WEXITSTATUS(status.value); } else if (WIFSIGNALED(status.value)) { exitValue = WTERMSIG(status.value); } else if (WIFSTOPPED(status.value)) { exitValue = WSTOPSIG(status.value); } else { throw new AssertionError("unexpected status from waitpid: " + status.value);
public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }
/** * Indicates if this file represents a <em>file</em> on the underlying * file system. * * @return {@code true} if this file is a file, {@code false} otherwise. */ public boolean isFile() { try { return S_ISREG(Libcore.os.stat(path).st_mode); } catch (ErrnoException errnoException) { // The RI returns false on error. (Even for errors like EACCES or ELOOP.) return false; } }
if (S_ISDIR(Libcore.os.fstat(fd).st_mode)) { throw new ErrnoException("open", EISDIR);
/** * Converts the stashed function name and errno value to a human-readable string. * We do this here rather than in the constructor so that callers only pay for * this if they need it. */ @Override public String getMessage() { String errnoName = OsConstants.errnoName(errno); if (errnoName == null) { errnoName = "errno " + errno; } return functionName + " failed: " + errnoName; }
public static int WSTOPSIG(int status) { return WEXITSTATUS(status); } public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
@Override public void close(FileDescriptor fd) throws ErrnoException { try { if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) { if (isLingerSocket(fd)) { // If the fd is a socket with SO_LINGER set, we might block indefinitely. // We allow non-linger sockets so that apps can close their network // connections in methods like onDestroy which will run on the UI thread. BlockGuard.getThreadPolicy().onNetwork(); } untagSocket(fd); } } catch (ErrnoException ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily // a socket at all. } os.close(fd); }
if (WIFEXITED(status.value)) { exitValue = WEXITSTATUS(status.value); } else if (WIFSIGNALED(status.value)) { exitValue = WTERMSIG(status.value); } else if (WIFSTOPPED(status.value)) { exitValue = WSTOPSIG(status.value); } else { throw new AssertionError("unexpected status from waitpid: " + status.value);
public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); } public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }