Last active
August 9, 2016 20:53
-
-
Save diogovk/e58f4be7cd7328d16cd2dbe040737448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// program_start | |
fd_log = open("logfile.log") | |
fn log(msg) { | |
fd_log.write(msg) | |
fd_log.flush() | |
} | |
log("something happened") | |
// program ends and all open file descriptors are closed by the OS | |
############################################## | |
// program_start do nothing | |
fn log(msg) { | |
// this function absolutely must be SYNC, otherwize we can end up opening the same file many times! | |
fd_log = open("logfile.log") | |
try { | |
fd_log.write(msg); | |
} finally { | |
fd_log.close() | |
} | |
} | |
log("something happened") | |
// program ends | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment