Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/IronPython.Modules/nt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,12 @@ static void linkWindows(string src, string dst) {
}

public static bool isatty(CodeContext context, int fd) {
if (context.LanguageContext.FileManager.TryGetStreams(fd, out var streams))
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
return isattyUnix(fd);
}
if (context.LanguageContext.FileManager.TryGetStreams(fd, out var streams)) {
return streams.IsConsoleStream();
}
return false;
}

Expand Down
25 changes: 17 additions & 8 deletions src/core/IronPython.Modules/posix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,16 @@ public static BigInteger geteuid() {
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
private static void utimeUnix(string path, long atime_ns, long utime_ns) {
var atime = new Timespec();
atime.tv_sec = atime_ns / 1_000_000_000;
atime.tv_nsec = atime_ns % 1_000_000_000;
var utime = new Timespec();
utime.tv_sec = utime_ns / 1_000_000_000;
utime.tv_nsec = utime_ns % 1_000_000_000;

if (Syscall.utimensat(Syscall.AT_FDCWD, path, new[] { atime, utime }, 0) == 0) return;
var atime = new Timespec {
tv_sec = atime_ns / 1_000_000_000,
tv_nsec = atime_ns % 1_000_000_000
};
var utime = new Timespec {
tv_sec = utime_ns / 1_000_000_000,
tv_nsec = utime_ns % 1_000_000_000
};

if (Syscall.utimensat(Syscall.AT_FDCWD, path, [atime, utime], 0) == 0) return;
throw GetLastUnixError(path);
}

Expand All @@ -225,6 +227,13 @@ private static void killUnix(int pid, int sig) {
throw GetLastUnixError();
}


[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
private static bool isattyUnix(int fd) {
return Syscall.isatty(fd);
}

#endif
}
}