Linux/POSIX equivalent for Win32’s CreateEvent, SetEvent, WaitForSingleObject

The POSIX equivalent for what you described is POSIX condition variables. Note that condition variable must always be used in pair with a POSIX mutex, but quite frequently several condition variables use the same mutex, so if you aren’t going to use the mutex exclusively for the condition variable, you shouldn’t place it in the … Read more

What can lead to “IOError: [Errno 9] Bad file descriptor” during os.system()?

You get this error message if a Python file was closed from “the outside”, i.e. not from the file object’s close() method: >>> f = open(“.bashrc”) >>> os.close(f.fileno()) >>> del f close failed in file object destructor: IOError: [Errno 9] Bad file descriptor The line del f deletes the last reference to the file object, … Read more

Redirect stdout to a file

While dealing with redirecting output to a file you may use freopen(). Assuming you are trying to redirect your stdout to a file ‘output.txt‘ then you can write- freopen(“output.txt”, “a+”, stdout); Here “a+” for append mode. If the file exists then the file open in append mode. Otherwise a new file is created. After reopening … Read more

Where does Microsoft Windows’ 7 POSIX implementation currently stand?

SUA, formerly called INTERIX, is now 100% POSIX compatible. There are a lot of ported apps for it. Even whole Linux distros like Debian have been ported. SUA/Interix comes with Windows 2003R2 and up (including Win7 which has the latest 6.1). I also successfully compiled BASH without it directly supporting SUA. Previously only parts of … Read more