Drop read + parse of /proc/sys/kernel/osrelease on startup

This has been obviated by the CMake-defined WSL #define.
This commit is contained in:
Mahmoud Al-Qudsi 2018-03-14 18:28:16 -05:00
parent f83b3a4f58
commit 2477a894e7

View file

@ -765,27 +765,14 @@ void misc_init() {
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
} }
#ifdef OS_IS_CYGWIN #if defined(OS_IS_CYGWIN) || defined(WSL)
// MS Windows tty devices do not currently have either a read or write timestamp. Those // MS Windows tty devices do not currently have either a read or write timestamp. Those
// respective fields of `struct stat` are always the current time. Which means we can't // respective fields of `struct stat` are always the current time. Which means we can't
// use them. So we assume no external program has written to the terminal behind our // use them. So we assume no external program has written to the terminal behind our
// back. This makes multiline prompt usable. See issue #2859 and // back. This makes multiline prompt usable. See issue #2859 and
// https://github.com/Microsoft/BashOnWindows/issues/545 // https://github.com/Microsoft/BashOnWindows/issues/545
has_working_tty_timestamps = false; has_working_tty_timestamps = false;
#else #endif
// This covers preview builds of Windows Subsystem for Linux (WSL).
FILE *procsyskosrel;
if ((procsyskosrel = wfopen(L"/proc/sys/kernel/osrelease", "r"))) {
wcstring osrelease;
fgetws2(&osrelease, procsyskosrel);
if (osrelease.find(L"3.4.0-Microsoft") != wcstring::npos) {
has_working_tty_timestamps = false;
}
}
if (procsyskosrel) {
fclose(procsyskosrel);
}
#endif // OS_IS_MS_WINDOWS
} }
static void env_universal_callbacks(callback_data_list_t &callbacks) { static void env_universal_callbacks(callback_data_list_t &callbacks) {