private int childResult(WindowsChildRecord child, boolean overlay) { if (child == null) return -1; if (overlay) { IntByReference exitCode = new IntByReference(); WindowsLibC libc = (WindowsLibC) libc(); HANDLE handle = child.getProcess(); libc.WaitForSingleObject(handle, WindowsLibC.INFINITE); libc.GetExitCodeProcess(handle, exitCode); libc.CloseHandle(handle); System.exit(exitCode.getValue()); } return child.getPid(); }
private int childResult(WindowsChildRecord child, boolean overlay) { if (child == null) return -1; if (overlay) { IntByReference exitCode = new IntByReference(); WindowsLibC libc = (WindowsLibC) libc(); HANDLE handle = child.getProcess(); libc.WaitForSingleObject(handle, WindowsLibC.INFINITE); libc.GetExitCodeProcess(handle, exitCode); libc.CloseHandle(handle); System.exit(exitCode.getValue()); } return child.getPid(); }
private int childResult(WindowsChildRecord child, boolean overlay) { if (child == null) return -1; if (overlay) { IntByReference exitCode = new IntByReference(); WindowsLibC libc = (WindowsLibC) libc(); HANDLE handle = child.getProcess(); libc.WaitForSingleObject(handle, WindowsLibC.INFINITE); libc.GetExitCodeProcess(handle, exitCode); libc.CloseHandle(handle); System.exit(exitCode.getValue()); } return child.getPid(); }
private int childResult(WindowsChildRecord child, boolean overlay) { if (child == null) return -1; if (overlay) { IntByReference exitCode = new IntByReference(); WindowsLibC libc = (WindowsLibC) libc(); HANDLE handle = child.getProcess(); libc.WaitForSingleObject(handle, WindowsLibC.INFINITE); libc.GetExitCodeProcess(handle, exitCode); libc.CloseHandle(handle); System.exit(exitCode.getValue()); } return child.getPid(); }
private int setFileTime(String path, FileTime aTime, FileTime mTime) { byte[] wpath = WindowsHelpers.toWPath(path); HANDLE handle = wlibc().CreateFileW(wpath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, null, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!handle.isValid()) { return -1; // TODO proper error handling } boolean timeSet = wlibc().SetFileTime(handle, null, aTime, mTime); wlibc().CloseHandle(handle); return timeSet ? 0 : -1; }
@Override public int utimes(String path, long[] atimeval, long[] mtimeval) { byte[] wpath = WindowsHelpers.toWPath(path); FileTime aTime = atimeval == null ? null : unixTimeToFileTime(atimeval[0]); FileTime mTime = mtimeval == null ? null : unixTimeToFileTime(mtimeval[0]); if (aTime == null || mTime == null) { FileTime nowFile = unixTimeToFileTime(System.currentTimeMillis() / 1000L); if (aTime == null) aTime = nowFile; if (mTime == null) mTime = nowFile; } HANDLE handle = wlibc().CreateFileW(wpath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, null, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!handle.isValid()) { return -1; // TODO proper error handling } boolean timeSet = wlibc().SetFileTime(handle, null, aTime, mTime); wlibc().CloseHandle(handle); return timeSet ? 0 : -1; }
@Override public int utimes(String path, long[] atimeval, long[] mtimeval) { byte[] wpath = WindowsHelpers.toWPath(path); FileTime aTime = atimeval == null ? null : unixTimeToFileTime(atimeval[0]); FileTime mTime = mtimeval == null ? null : unixTimeToFileTime(mtimeval[0]); if (aTime == null || mTime == null) { FileTime nowFile = unixTimeToFileTime(System.currentTimeMillis() / 1000L); if (aTime == null) aTime = nowFile; if (mTime == null) mTime = nowFile; } HANDLE handle = wlibc().CreateFileW(wpath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, null, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!handle.isValid()) { return -1; // TODO proper error handling } boolean timeSet = wlibc().SetFileTime(handle, null, aTime, mTime); wlibc().CloseHandle(handle); return timeSet ? 0 : -1; }
@Override public int utimes(String path, long[] atimeval, long[] mtimeval) { byte[] wpath = WindowsHelpers.toWPath(path); FileTime aTime = atimeval == null ? null : unixTimeToFileTime(atimeval[0]); FileTime mTime = mtimeval == null ? null : unixTimeToFileTime(mtimeval[0]); if (aTime == null || mTime == null) { FileTime nowFile = unixTimeToFileTime(System.currentTimeMillis() / 1000L); if (aTime == null) aTime = nowFile; if (mTime == null) mTime = nowFile; } HANDLE handle = wlibc().CreateFileW(wpath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, null, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!handle.isValid()) { return -1; // TODO proper error handling } boolean timeSet = wlibc().SetFileTime(handle, null, aTime, mTime); wlibc().CloseHandle(handle); return timeSet ? 0 : -1; }
@Override public int waitpid(int pid, int[] status, int flags) { if (pid <= 0) { handler.unimplementedError("waitpid"); } HANDLE h = wlibc().OpenProcess(WindowsLibC.PROCESS_QUERY_INFORMATION, 0, pid); if (h == null) { return -1; // TODO: Throw exception } // Block if ((flags & WaitFlags.WNOHANG.intValue()) != 0) { wlibc().WaitForSingleObject(h, WindowsLibC.INFINITE); } IntByReference exitCode = new IntByReference(); wlibc().GetExitCodeProcess(h, exitCode); wlibc().CloseHandle(h); int code = exitCode.getValue(); if (code == 259) { return 0; } else { status[0] = code; return pid; } }
wlibc().CloseHandle(processInformation.getThread());
wlibc().CloseHandle(processInformation.getThread());
wlibc().CloseHandle(processInformation.getThread());
wlibc().CloseHandle(processInformation.getThread());