Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:07:56+00:00 2026-05-31T19:07:56+00:00

Disclaimer: This is for a programming class, but it is not the answer or

  • 0

Disclaimer: This is for a programming class, but it is not the answer or purpose of the assignment.

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.

Under a Solaris based server, everything works:

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'

Under a Linux based server, I see this:

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

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 SA_RESTART 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?

UPDATE:

I used gcc -M to determine which files are included in my compile on each machine and then used grep to try to find the definition. So far these are my results:

(On Solaris)

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 <features.h>
#include <bits/sigset.h>                /* __sigset_t, __sig_atomic_t.  */
#include <bits/types.h>
#include <bits/signum.h>
xxxxxxx@xxx:~/proj6$ grep "#include" /usr/include/sys/signal.h
#include <sys/feature_tests.h>
#include <sys/iso/signal_iso.h>
#include <sys/siginfo.h>
#include <sys/ucontext.h>
#include <sys/t_lock.h>

(On Linux)

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$

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?

Update #2: contents of /usr/include/sys/signal.h on Linux is just `#include

Update #3: output of grep -r SA_RESTART /usr/include

/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

So it resides in a file called sigaction.h (which makes sense) and that file is being included (verified with gcc -M), so why is the compiler complaining?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:07:58+00:00Added an answer on May 31, 2026 at 7:07 pm

    It’s due to your -D flag:

    #include <signal.h>
    #include <stdio.h>
    
    int main(void) {
    #ifdef SA_RESTART
        puts("have SA_RESTART");
    #else
        puts("no SA_RESTART");
    #endif
        return 0;
    }
    
    $ cc foo.c && ./a.out
    have SA_RESTART
    $ gcc -std=c99 -Wall -Wextra -D_POSIX_C_SOURCE=200112L -D_POSIX_PTHREAD_SEMANTICS foo.c && ./a.out
    no SA_RESTART
    $ gcc -std=c99 -Wall -Wextra -D_POSIX_C_SOURCE=200809L -D_POSIX_PTHREAD_SEMANTICS foo.c && ./a.out
    have SA_RESTART
    

    In particular, "200112L" means "don’t give me SA_RESTART". See /usr/include/features.h.

    Edit: as Andrew Henle notes in a comment, this particular Linux features.h is (or was back in 2012) just plain wrong here: see the SUS spec from 1997. Still, if it’s wrong in whatever system you’re using, you may need to work around that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer: This is for a homework assignment, but the question is not regarding the
Not so much a question to help my own programming, but I found this
Full disclaimer: this is not really a homework, but I tagged it as such
Disclaimer: I am new to python and django but have Drupal programming experience. I'm
Disclaimer: this question is directly related to my programming homework. My C++ assignment consists
Disclaimer: I am new to python and django but have experience programming in Drupal.
( Disclaimer: This question is not specific to ASP.NET) I have a control which
Disclaimer : this is not a how to question. I would more like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.