title: SA_RESTART not defined under Linux, compiles fine in Solaris
body: <p><strong>Disclaimer:</strong> This is for a programming class, but it is <strong>not</strong> the answer or purpose of the assignment. </p>
  
  <p>We have access to multiple *nix-like servers in my university, and are encouraged to compile our projects on each of them to see how different environments change things. I'm currently doing a project that involves signals and I've hit a difference that I cannot fix myself.</p>
  
  <p>Under a Solaris based server, everything works:</p>
  
  <pre><code>xxxxxxx@xxx:~/proj6$ make gcc-new
  rm -f ./pr6
  gcc -std=c99 -Wall -Wextra -D_POSIX_C_SOURCE=200112L -D_POSIX_PTHREAD_SEMANTICS -o pr6 pr6.2.c pr6_ctime.c pr6_signal.c
   pr6_signal.c:64: warning: unused parameter 'sig'
   pr6_signal.c:64: warning: unused parameter 'func'
  </code></pre>
  
  <p>Under a Linux based server, I see this:</p>
  
  <pre><code>xxxxxxx@xxxxx:~/proj6$ make gcc-new
  rm -f ./pr6
  gcc -std=c99 -Wall -Wextra -D_POSIX_C_SOURCE=200112L -D_POSIX_PTHREAD_SEMANTICS  -o pr6  pr6.2.c pr6_ctime.c pr6_signal.c
  pr6_signal.c: In function âinstall_signal_handlerâ:
  pr6_signal.c:45: error: âSA_RESTARTâ undeclared (first use in this function)
  pr6_signal.c:45: error: (Each undeclared identifier is reported only once
  pr6_signal.c:45: error: for each function it appears in.)
  pr6_signal.c: In function âreinstall_signal_handlerâ:
  pr6_signal.c:64: warning: unused parameter âsigâ
  pr6_signal.c:64: warning: unused parameter âfuncâ
  make: *** [gcc-new] Error 1
  </code></pre>
  
  <p>I've fiddled around with different combinations of c99, POSIX 2001-12, and POSIX pthread to no avail. I don't understand why it is that <code>SA_RESTART</code> would not be defined under Linux as it is part of the POSIX standard and I've included that flag on GCC. If I forgot to #include something then it should be absent on both systems, no?</p>
  
  <p>UPDATE:</p>
  
  <p>I used <code>gcc -M</code> to determine which files are included in my compile on each machine and then used <code>grep</code> to try to find the definition. So far these are my results:</p>
  
  <p>(On Solaris)</p>
  
  <pre><code>xxxxxxx@xxx:~/proj6$ grep "SA_RESTART" /usr/include/sys/signal.h
  #define SA_RESTART      0x000004
  xxxxxxx@xxx:~/proj6$ grep "SA_RESTART" ./linux-signal.h
  xxxxxxx@xxx:~/proj6$
  
  
  
  xxxxxxx@xxx:~/proj6$ grep "#include" ./linux-signal.h
  #include &lt;features.h&gt;
  #include &lt;bits/sigset.h&gt;                /* __sigset_t, __sig_atomic_t.  */
  #include &lt;bits/types.h&gt;
  #include &lt;bits/signum.h&gt;
  xxxxxxx@xxx:~/proj6$ grep "#include" /usr/include/sys/signal.h
  #include &lt;sys/feature_tests.h&gt;
  #include &lt;sys/iso/signal_iso.h&gt;
  #include &lt;sys/siginfo.h&gt;
  #include &lt;sys/ucontext.h&gt;
  #include &lt;sys/t_lock.h&gt;
  </code></pre>
  
  <p>(On Linux)</p>
  
  <pre><code>xxxxxxx@xxxxx:~/proj6$ grep "SA_RESTART" /usr/include/features.h
  xxxxxxx@xxxxx:~/proj6$ grep "SA_RESTART" /usr/include/bits/sigset.h 
  xxxxxxx@xxxxx:~/proj6$ grep "SA_RESTART" /usr/include/bits/types.h
  xxxxxxx@xxxxx:~/proj6$ grep "SA_RESTART" /usr/include/bits/signum.h
  xxxxxxx@xxxxx:~/proj6$
  </code></pre>
  
  <p>So there is no definition for SA_RESTART in any of the files being included under Linux (the compiler told me this to start with) so the question is WHY?</p>
  
  <p>Update #2: contents of <code>/usr/include/sys/signal.h</code> on Linux is just `#include 
  
  <p>Update #3: output of <code>grep -r SA_RESTART /usr/include</code></p>
  
  <pre><code>/usr/include/bits/sigaction.h:# define SA_RESTART   0x10000000 /* Restart syscall on signal return.  */
  /usr/include/asm-generic/signal.h: * SA_RESTART flag to get restarting signals (which were the default long ago)
  /usr/include/asm-generic/signal.h:#define SA_RESTART    0x10000000
  Binary file /usr/include/c++/3.4.6/x86_64-redhat-linux/bits/stdc++.h.gch/O2g matches
  Binary file /usr/include/c++/3.4.6/x86_64-redhat-linux/bits/stdc++.h.gch/O0g matches
  /usr/include/mysql/my_pthread.h:  as Mac OS X, sigset() results in flags such as SA_RESTART being set, and
  /usr/include/asm/signal.h: * SA_RESTART flag to get restarting signals (which were the default long ago)
  /usr/include/asm/signal.h:#define SA_RESTART    0x10000000u
  grep: warning: /usr/include/gphoto2/gphoto2: recursive directory loop
  
  /usr/include/valgrind/vki/vki-ppc64-linux.h:#define VKI_SA_RESTART      0x10000000u
  /usr/include/valgrind/vki/vki-darwin.h:#define VKI_SA_RESTART   SA_RESTART
  /usr/include/valgrind/vki/vki-ppc32-linux.h:#define VKI_SA_RESTART              0x10000000
  /usr/include/valgrind/vki/vki-x86-linux.h:#define VKI_SA_RESTART                0x10000000u
  /usr/include/valgrind/vki/vki-s390x-linux.h: * SA_RESTART flag to get restarting signals (which were the default long ago)
  /usr/include/valgrind/vki/vki-s390x-linux.h:#define VKI_SA_RESTART      0x10000000
  /usr/include/valgrind/vki/vki-amd64-linux.h:#define VKI_SA_RESTART              0x10000000
  /usr/include/valgrind/vki/vki-arm-linux.h:#define VKI_SA_RESTART                0x10000000u
  </code></pre>
  
  <p>So it resides in a file called sigaction.h (which makes sense) and that file is being included (verified with <code>gcc -M</code>), so why is the compiler complaining?</p>