Underhanded contest: The OS war

Python

This program opens the image specified on the command line and displays it.

import Image
import sys

with open(sys.argv[1]) as f:
    im = Image.open(f)
    im.show()

Works on linux, does not work on windows.

This is due to the way windows opens files. Binary mode must be specified for this to work properly on all operating systems.


Unix shell + standard utilities

Let's write a shell script that finds the process (owned by any user) that has used the most CPU time, and kills all processes with the same name. I suppose that counts as reading in data (from the system) and performing a calculation. (That behavior could be useful for processes that fork off many processes, such as fork bombs and Google Chromium.)

The following should be a portable way to get the name of the process with the greatest CPU time (I tried to avoid obvious Linuxisms but haven't tested it on Solaris):

ps -A -o time= -o comm= | sort | tail -n 1 | cut -d ' ' -f 2

So our script is simply

killall `ps -A -o time= -o comm= | sort | tail -n 1 | cut -d ' ' -f 2`

Run as root for best results, so that it can kill processes from other users.

Linux and BSD

This works on Linux and should work on the BSDs, because killall arg kills processes named arg.

Solaris

However, on Solaris, if a user happens to be running a program named 9 in an infinite loop, the script will bring down the system. This is because:

On Solaris, killall arg means to kill all processes with the signal arg. So the command line becomes killall 9. As 9 is the number for SIGKILL on Solaris, this will kill all processes and thereby bring down the system.

N.B.

This shell injection issue doesn't apply on Linux, because even though the malicious user could supply some special argument like -KILL as a process name, killall -KILL will harmlessly print a usage message.


GTB

:"-→_[_+_→_]

On the computer it works, but on my TI-84 calculator it doesn't. Why?

On the calculator RAM overflows and is potentially cleared, while on the emulator for Windows, RAM cannot be overflown by the emulator because of limited allocation.