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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:47:57+00:00 2026-06-12T01:47:57+00:00

I am currently working on a some C code, very new to C, so

  • 0

I am currently working on a some C code, very new to C, so apologize if this is a bit basic or a stupid question.

I have the following code which is executed within a thread using pthread_create().

if (ps.status == completed)
        {
            LOG(LOG_AUDIO, "evsafewait_sm_play_tone:\tPlay tone complete");
            if (e2)
            {
                LOG(LOG_MUST, "Failed to free tone event. Result: %i", e2);
            }

            pccb->playToneComplete = 1;
            LOG(LOG_AUDIO, "Detatching thread ID %x", manageToneParms->toneManagerThread);
            //pthread_detach(manageToneParms->toneManagerThread);

            int retVal;
            pthread_exit(&retVal);
            LOG(LOG_AUDIO, "THREAD TERMINATED WITH RESULT %i", retVal);
            LOG(LOG_AUDIO, "Freeing memory");

            free(manageToneParms->playToneParms);
            free(manageToneParms);
            return 0;
        }  

Before the structures are free and the method returns I am trying to exit the thread using pthread_exit() but when this is called, everything below it is skipped, no errors are displayed, as far as I can see anyway.

I have tried debugging it with GDB and when pthread_exit() is called the next thing it prints out is siglongjmp, I have no idea what this is, I don’t believe it’s in the C code, at least not in the changes that I have been making to it.

How can I exit this thread? I’ve also tried pthread_exit(NULL) and pthread_kill(threadID, SIGKILL) but then this kills the whole program not just the thread.

  • 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-12T01:47:58+00:00Added an answer on June 12, 2026 at 1:47 am

    pthread_exit() returns from the thread at the point of the call. Any code after pthread_exit() will not be executed.

    You should be sure to release any memory allocated in the thread before calling pthread_exit().

    Have you tried something like this:?

    int retVal;
    
    /* free resources -- make sure all resources allocated in thread 
       function are released 
    */
    free(manageToneParms->playToneParms);
    free(manageToneParms);
    
    LOG(LOG_AUDIO, "THREAD TERMINATED WITH RESULT %i", retVal);
    LOG(LOG_AUDIO, "Freeing memory");
    pthread_exit(&retVal);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to programming, so I apologize if this question seems absurdly
Hi I have been working on this code today after attempting some of the
I am currently working on some Ajax heavy code and I am wondering how
I am currently working with some users that do not have the .NET Framework
I'm currently working through some exercises in a c++ book, which uses text based
I am currently working on some simple custom allocators in c++ which generally works
I am working on some code that deals with date ranges. I have pricing
I'm new to SQL Server. Currently I'm working on an existing source code and
I am currently trying to write some code which is going to send a
I am currently working on some code that requires a comparison of dates as

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.