process semaphores cleanup problem

This is a discussion on process semaphores cleanup problem within the Linux Programming forums, part of the Platform Specific Boards category; Hi all, My is probem is that I want to do some cleanup action if a process gets ki lled. ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    2

    Unhappy process semaphores cleanup problem

    Hi all,

    My is probem is that I want to do some cleanup action if a process gets ki
    lled. Is there any way I can attach a cleanup routine ( like pthread_cleanup
    _push: in case of pthreads) in a process (not a thread)


    Actually My process deals with shared memory & semaphores...& if it gets ki
    lled while semaphore is in locked state...there occurs a problem...(others p
    rocessess can no longer use that shared memory resource)
    So I want to install a Cleanup Handler ( in C language on linux platform) so
    as to unlock the semaphores just prior to termination.


    Help me guys...........

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Look into signal handlers.
    Then trap on say SIG_QUIT

    You won't be able to trap SIG_KILL
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 01:14 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  4. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  5. process ring
    By gregulator in forum C++ Programming
    Replies: 0
    Last Post: 02-28-2005, 07:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21