Perl, 108 bytes, 256 exit codes
This program (ab)uses Test::More module. It tries to open file named "" n times where n is given as command line argument. It fails every time, and each invocation is treated as a test. Test::More return number of failed tests as exit code. plan tests => %ARGV[0]$ARGV[0]%255 is needed to get exit code 255.
#!/usr/bin/perl use Test::More; plan tests => $ARGV[0]%255 if($ARGV[0]>0); ok(open(F,"")) for (1..$ARGV[0])