LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2007, 12:12 PM   #1
xface66
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Rep: Reputation: 15
overriding SIGINT


Hello everyone,
i am writing a program uses shared memory with semaphores and i use fork() mechanism for child process.
My program will run until the user hits ctrl+C.
But when it is hit, i must stop the child process, detach and deallocate the shared memory and then exit. How can i achieve this?

i tried signal and defined a handler function but i cannot pass any other necessary arguments to it. It takes only one int signum. Do u have any suggestions?

Thanks in advance.
 
Old 04-01-2007, 01:30 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Create another shared memory area and keep all the data you need in that area, so you can get access to it. Or you can use global variables.
 
Old 04-01-2007, 02:14 PM   #3
xface66
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
if i create another shared memory the same problem occurs again.

I don't want to use global variable. Do u have another suggestions?
 
Old 04-02-2007, 01:32 PM   #4
nmh+linuxquestions.o
Member
 
Registered: Feb 2007
Posts: 135

Rep: Reputation: 15
Are you asking how to deal with getting the signal and then doing something?

Are you asking how to clean up the shared memory?

Or are you asking how to do both of these?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SIGINT problem brentos Linux - General 1 12-17-2008 10:43 PM
SIGINT handling santhosh.bachu Linux - General 1 07-18-2006 01:18 AM
in bash does control-c = SIGINT or SIGTERM? walterbyrd Linux - General 2 05-09-2006 11:01 AM
What is function overriding in C skie_knite007 Programming 2 03-11-2005 12:29 PM
What is function overriding in C skie_knite007 Programming 7 03-11-2005 11:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration