title: How can the exit status of a process depend on whether it's statically built?
body: <p>A modern system:</p>
  
  <pre><code>% pacman -Q glibc gcc
  glibc 2.16.0-4
  gcc 4.7.1-6
  % uname -sr
  Linux 3.5.4-1-ARCH
  </code></pre>
  
  <p>A trivial program:</p>
  
  <pre><code>% &lt; wtf.c   
  void main(){}
  </code></pre>
  
  <p>Let's do static and dynamic builds:</p>
  
  <pre><code>% gcc -o wtfs wtf.c -static                               
  % gcc -o wtfd wtf.c
  </code></pre>
  
  <p>Everything looks fine:</p>
  
  <pre><code>% file wtf?                                             
  wtfd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x4b421af13d6b3ccb6213b8580e4a7b072b6c7c3e, not stripped
  wtfs: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=0x1f2a9beebc0025026b89a06525eec5623315c267, not stripped
  </code></pre>
  
  <p>Could anybody explain this to me?</p>
  
  <pre><code>% for n in $(seq 1 10); do ./wtfd; echo $?; done | xargs
  0 0 0 0 0 0 0 0 0 0
  % for n in $(seq 1 10); do ./wtfs; echo $?; done | xargs
  128 240 48 128 128 32 64 224 160 48
  </code></pre>
  
  <p>Sure, one can use <code>int main()</code>. And <code>-Wmain</code> will issue a warning (<code>return type of ‘main’ is not ‘int’</code>).</p>
  
  <p>I'd just like to understand what is going on there.</p>