5 ms·
Which is, actually, far too large due to the standard library, program state initialization, and stack frame management. If there's ever a practical use for cod
by kobeya 9y ago
Which is, actually, far too large due to the standard library, program state initialization, and stack frame management. If there's ever a practical use for code golf, this is probably it. /bin/true should be a bare minimum ELF executable with no stack or heap that does nothing except immediately make the system call to terminate.
- cat199 9y agoAs mentioned in the article: " This can be done with an empty file that's marked executable, and that's what it was in the earliest unix system libraries. " $ uname -sr OpenBSD 6.1 $ install -m 755 /dev/null /tmp/muhtrue && /tmp/muhtrue && echo yup yup not sure why it was ever switched.. probably the 'return 0;' version is cheaper than a shell fork? hmm..
- slezyr 9y agoWell this code might do exactly what you just said. Everything depends with which compiler flags you build this code. I know for sure there are MSVS flags to build this program with no runtime and other things with just return asm op in it.
- ben_bai 9y agoMost likely nobody uses /bin/true (/usr/bin/true). Executing true without the pathname will run the shell embedded function.
- kobeya 9y agoNeeding a program that returns true comes up more often than just shell scripting. For example, maybe a system reports an event by launching a named executable. Specifying /bin/true is the equivalent of redirecting that event to /dev/null.
- maxlybbert 9y agohttp://www.muppetlabs.com/~breadbox/software/tiny/teensy.html http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...