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 8672789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:17:31+00:00 2026-06-12T19:17:31+00:00

So, this code was working just fine until recently, when we decided to move

  • 0

So, this code was working just fine until recently, when we decided to move it to a Lubuntu 12.04 system. The call to timer_settime returns EINVAL, and running it under gdb I’ve confirmed that all of the fields of ts are within 0 and 999999999 at the time that it is called:

1067        if(-1 ==timer_settime(tid,0,&ts,NULL))
(gdb) print ts
$1 = {it_interval = {tv_sec = 0, tv_nsec = 200000000}, it_value = {tv_sec = 0,
tv_nsec = 0}}

Since this should be the only thing that can cause it to return EINVAL I’m very much puzzled. Maybe there’s something obvious here that i’m missing.

struct sigevent sev;
struct itimerspec ts;
timer_t *tid;
//actually point the pointer at something.
tid = calloc(1,sizeof(timer_t));
//make sure there's no garbage in the structures.
memset(&sev,0,sizeof(struct sigevent));
memset(&ts,0, sizeof(struct itimerspec));
//notify via thread
sev.sigev_notify = SIGEV_THREAD;
sev.sigev_notify_function = SwitchThreadHandler;
sev.sigev_notify_attributes = NULL;
sev.sigev_value.sival_ptr = tid;
ts.it_value.tv_sec =0;
ts.it_value.tv_nsec = 0;
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 200000000;
if(-1 == timer_create(CLOCK_REALTIME,&sev,tid))
{
    retval = EX_SOFTWARE;
    fprintf(stderr,"Failed to create timer.");
    free(tid);
    return retval;
}

if(-1 ==timer_settime(tid,0,&ts,NULL))
{
    int errsv = errno;
    fprintf(stderr,"timer_settime FAILED!!!\n");
    if(errsv == EINVAL)
    {
        fprintf(stderr,"INVALID VALUE!\n");
    }
    else
    {
        fprintf(stderr,"UNKOWN ERROR: %d\n",errsv);
    }
    return EX_SOFTWARE;
}
  • 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-06-12T19:17:32+00:00Added an answer on June 12, 2026 at 7:17 pm

    timer_settime is documented as taking a timer_t as the first argument, not a timer_t * like timer_create. It will fail with EINVAL if timerid is invalid.

    Therefore, you should pass *tid as the first argument.

    Note that your compiler should have issued a warning for this.

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

Sidebar

Related Questions

This code was working fine until i went to firefox 4 and now it
I am working on const-correctness of my code and just wondered why this code
What does this mean? My page had been working fine until this suddenly appeared
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
Why isn't this code working? I've been stuck on this for 2 days. public
I used to have this code working with my Tomcat server: HttpRequestBase targetRequest =
i got this code working and it to return the last tweet from my
I tried everything to get this code working, and I hope someone will save
Simple question, how make this code working ? public class T { public static
this seems to be weird but it really happened. I have this code working

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.