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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:27:09+00:00 2026-06-07T12:27:09+00:00

I have a 3rd party application written in C for Linux platform. The application

  • 0

I have a 3rd party application written in C for Linux platform. The application creates semaphores using below code:

union semun {
    int Value;
    struct semid_ds *Buffer;
    unsigned short * Array;
} Arg;

Arg.Value = 0;

SemId = semget(IPC_PRIVATE , ONE_SEMAPHORE, 0666 | IPC_CREAT);

semctl(SemId, 0, SETVAL, Arg);

When the application exits, these semaphores are deleted by the application using below code:

semctl(SemId, 0, IPC_RMID);

If the application is stopped abnormally (such as by sending multiple SIGINT signals), these semaphores remain open. These semaphores can be seen open by using below command:

ipcs -s

These semaphores have to be removed from the system manually by using ipcrm command.

How can I ensure that the semaphores created by the application get deleted when the application finally exits? I have read that exit() call closes all open named semaphores. However these are not named semaphores.

I thank you in advance for your help.

  • 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-07T12:27:12+00:00Added an answer on June 7, 2026 at 12:27 pm

    For handling Abnormal terminations we can install the signal handlers

    /* signal handlers available in signal.h */
    #include <signal.h>
    
    void SignalHandler(int iSignalNum)
    {
        switch(iSignalNum)
        {
        case SIGINT:
        case SIGSEGV:
        case SIGTSTP:
            {
               /* Add Stuffs if necessary */
               semctl(SemId, 0, IPC_RMID);
            }
         break;
         default:
            break;
        }
       exit(0); 
    }        
    
    
    int main()
    {
            ....
    
            /* Register the signal handlers */
            signal(SIGINT,  SignalHandler);
            signal(SIGSEGV, SignalHandler);
            signal(SIGTSTP, SignalHandler);
            .....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET application written in C#. My application uses 3rd party libraries,
I am using Zend Framework and 3rd party application written in php for file
Hi I have a reporting application written against some 3rd party software. Unfortunately it
I have already created a Macro using a 3rd party application that does what
I have a 3rd party client/server application, not developed by me, who needs to
I have access to a 3rd party PropertyGrid within my application (C#. ,Net v2).
We have Win Forms application uses the 3rd party windows native controls. Can these
We have a system that makes a use of 3rd party COM DLL written
I'm have access to a 3rd party application's database, and I see a field
I have a 3rd party application that doesn't come with an installer. It's a

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.