Sponsored Content
Full Discussion: Using Signals
Top Forums Programming Using Signals Post 2824 by kapilv on Wednesday 6th of June 2001 01:59:11 PM
Old 06-06-2001
Using Signals

How can use signals in a C program If i want a child program to signal it's parent program that it(child) program has completed the task that it was assigned.Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

Signals In HP-UX

does the way of handling, interrupting signals in HP-UX same as that of solaris. If there is difference than what it is.?:confused: (1 Reply)
Discussion started by: kapilv
1 Replies

2. UNIX for Dummies Questions & Answers

Signals...

(posted this in the scripting forum as well, but figured it should go here) So, what's going on is this: For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground process running, let's... (0 Replies)
Discussion started by: blind melon
0 Replies

3. UNIX for Dummies Questions & Answers

threads and signals

can any one give me an example of a concurrency program in threads and signals, i.e how to deliver messages between threads using signals. thanks (0 Replies)
Discussion started by: moe_7
0 Replies

4. Programming

threads and signals

can any one give me an example of a concurrency program in threads and signals, i.e how to deliver messages between threads using signals. thanks (2 Replies)
Discussion started by: moe_7
2 Replies

5. OS X (Apple)

How to debug signals

Hi, In our program, we are using SIGTERM and i tired to put break point in this function. But my debuger is unable to brake at that point. I am working on Mac X and using XCode. Thanks (0 Replies)
Discussion started by: Saurabh78
0 Replies

6. Programming

Can we debug Signals

Hi, In our program, we are using SIGTERM and i tired to put break point in this function. But my debuger is unable to brake at that point. I am working on Mac X and using XCode. Thanks (1 Reply)
Discussion started by: Saurabh78
1 Replies

7. UNIX for Dummies Questions & Answers

Help understanding signals

I am having trouble with folowing sigset_t s; // now s represents set of signals sigemptyset(&s) ; // initialize this set and exclude all the signals from it.is it empty? sigaddset(&s,SIGILL);//this set containts only SIGILL signal sigprocmask(SIG_BLOCK,&s,NULL);//lost on this one Can... (3 Replies)
Discussion started by: joker40
3 Replies

8. UNIX for Dummies Questions & Answers

perror with signals

I have following problem with this code.. First time trough the main loop..... perror gives ....blocked signal:success(all other times gives illlegal seek) Should every time trought the main loop be success?? And the perror otside of main loop...didn't change mask:success That line of code... (2 Replies)
Discussion started by: joker40
2 Replies

9. UNIX for Dummies Questions & Answers

Blocking signals

I know how to add signal to a set. But what if I want to add 2 or 3 signals to the set. I know I can use sigaddset (&set,SIGBUS)....but what if I want to add SIGBUS and SIGALRM at once. Do i have to do it like this.. sigaddset (&set,SIGBUS); sigaddset (&set,SIGALRM); Is there another way to... (0 Replies)
Discussion started by: joker40
0 Replies

10. UNIX for Advanced & Expert Users

Help with Signals

Hi All, The problem statement is as below: Problem: A process (exe) is getting executed in background. The output of this process is getting logged in a file. After successfully running for some time the process gets terminated. In the log file following is present: ^M[7m Interrupt ^M[27m... (8 Replies)
Discussion started by: Praty.27
8 Replies
pthread_atfork(3)					     Library Functions Manual						 pthread_atfork(3)

NAME
pthread_atfork - Declares fork handler routines to be called when the calling thread's process forks a child process. LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <pthread.h> int pthread_atfork( void (*prepare)(void), void (*parent)(void), void (*child)(void)); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: IEEE Std 1003.1c-1995, POSIX System Application Program Interface PARAMETERS
Address of a routine that performs the fork preparation handling. This routine is called in the parent process before creating the child process. Address of a routine that performs the fork parent handling. This routine is called in the parent process after creating the child process and before returning to the caller of fork(2). Address of a routine that performs the fork child handling. This routine is called in the child process before returning to the caller of fork(2). DESCRIPTION
This routine allows a main program or library to control resources during a fork(2) operation by declaring fork handler routines, as fol- lows: The fork handler routine specified in the prepare argument is called before fork(2) executes. The fork handler routine specified in the parent argument is called after fork(2) executes within the parent process. The fork handler routine specified in the child argument is called in the new child process after fork(2) executes. Your program (or library) can use fork handlers to ensure that program context in the child process is consistent and meaningful. After fork(2) executes, only the calling thread exists in the child process, and the state of all memory in the parent process is replicated in the child process, including the states of any mutexes, condition variables, and so on. For example, in the new child process there might exist locked mutexes that are copies of mutexes that were locked in the parent process by threads that do not exist in the child process. Therefore, any associated program state might be inconsistent in the child process. The program can avoid this problem by calling pthread_atfork to provide routines that acquire and release resources that are critical to the child process. For example, the prepare handler should lock all mutexes that you want to be usable in the child process. The parent handler just unlocks those mutexes. The child handler will also unlock them all--and might also create threads or reset any program state for the child process. If no fork handling is desired, you can set any of this routine's arguments to NULL. NOTES
It is not legal to call pthread_atfork from within a fork handler routine. Doing so could cause a deadlock. EXAMPLES
For example, if your library uses a mutex my_mutex, you might provide pthread_atfork handler routines coded as follows: void my_prepare(void) { pthread_mutex_lock(&my_mutex); } void my_parent(void) { pthread_mutex_unlock(&my_mutex); } void my_child(void) { pthread_mutex_unlock(&my_mutex); /* Reinitialize state that doesn't apply...like heap owned */ /* by other threads */ } { . . . pthread_atfork(my_prepare, my_parent, my_child); . . fork(); } RETURN VALUES
If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows: Successful completion Insufficient table space exists to record the fork handler routines' addresses. ERRORS
None RELATED INFORMATION
Functions: pthread_create(3) Manuals: Guide to DECthreads, Programmer's Guide delim off pthread_atfork(3)
All times are GMT -4. The time now is 05:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy