Sponsored Content
Full Discussion: Problem due to Fork Error
Top Forums UNIX for Advanced & Expert Users Problem due to Fork Error Post 302212228 by Amey Joshi on Monday 7th of July 2008 02:19:17 AM
Old 07-07-2008
Quote:
Originally Posted by matrixmadhan
there are two approaches to this.
1) set a timer in the child - which generates SIGALRM after specified 'n' units of time, register handler for that signal and in the handler, it should terminate itself

2) have a controller program which takes care of creating new process on need, monitoring them and if it lives more than the threshold trigger it with a signal and accordingly in the child register handler for that signal and it should terminate.

Both the methods are doable, and you will have more control with the second approach, as number of child to be spawned, time for which child should live everything can be configured in the invoker process
Thanks for your reply!Smilie

Can you please tell me Second Method in detail..means which all commands i have to use(any sample)Smilie ...I am quite new to unix.... Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

fork problem

Hi, Consider the following piece of code: int main(void) { int i; pid_t pidp; for (i=0;i<4;i++) { switch (pidp=fork()) { case -1: fprintf(stdout, "Error during fork.\n"); exit (1); case 0: fprintf(stdout, "From child: I am... (4 Replies)
Discussion started by: qntmteleporter
4 Replies

2. Programming

fork() problem

i'm just trying to make 2 process read from the same 1 line a time. For some reason only the child reads. #include<stdio.h> #include <sys/types.h> void getlinefromfilep(void); void getlinefromfilec(void); int see=0; FILE * fileptr1; //need globe variable to tell pro3 to stop main()... (3 Replies)
Discussion started by: ddx08
3 Replies

3. Filesystems, Disks and Memory

ACL problem due to mv command used in solaris

Hi All, Is there any way to use mv command and that should apply ACL on the moved files that is already set in distination location This mv command is running in a solaris system. File system is NFS. Problem I am facing : Currently mv command removes ACL from moved files and also it... (0 Replies)
Discussion started by: Tlogine
0 Replies

4. Shell Programming and Scripting

Script problem due to recursive directories Help please

Hello everyone , I am looking for a better solution then the one I have created for the my Task The task is: Create an automated script that will check for Uploads in a specified Directory and move them to another specified Directory if the files are completely uploaded. Files are FTP'd to... (2 Replies)
Discussion started by: robertmcol
2 Replies

5. Programming

problem implementing fork

Hi, I was honing my linux programming skill when this nuisance started bugging me. I wanted to create an empty file creator program. While creating a large file it must print # for progress bar. But the output shows it happening reverse way. ie. first it copies file and shows the progress... (7 Replies)
Discussion started by: dheerajsuthar
7 Replies

6. SCO

Booting problem due to adding hard drive incorrectly

I have tried to (unsuccessfully) add an old drive to get drivers (for the 3Com network card) onto a Sco Openserver 5.1 server. Now it wont boot: I used Sco Admin to do this. It have 3 scuzzi drives I added an IDE I think what I did wrong was add the IDE to existing space, and I should not have... (6 Replies)
Discussion started by: lappies67
6 Replies

7. IP Networking

FTP failure due to network problem

Hi, I've been searching through out this forum to find the exact message when during the on-going FTP, suddenly the network went down but i cannot find some. Could anyone provide me the exact return codes when FTP failed during FTP or prior to FTP the network went down and you still proceeded to... (3 Replies)
Discussion started by: vibora
3 Replies

8. Programming

help in C of fork() problem

i am a beginner of C, and i tired to fork multiple child and all of them belongs to same parents and each of child responsible for printing individual data. but i don't have any idea how to do...... Can any body help? thanks a lot really. (7 Replies)
Discussion started by: wendy1089
7 Replies

9. Programming

problem with mutltiple fork()

Hi, can someone please help me with creating mutltiple fork.. I was expecting something like this: I am a child: 1 PID: 1215 I am a child: 2 PID: 1216 I am a child: 3 PID: 1217 I am a child: 4 PID: 1218 I am a child: 5 PID: 1219 I am a child: 6 PID: 1215 I am a child: 7 PID: 1216 I am a... (4 Replies)
Discussion started by: Placenzo
4 Replies

10. UNIX for Dummies Questions & Answers

Very basic problem with fork() using c

Hi guys, I have the following code: int main(int argc, char *argv) { int pid1,pid2,i=0; pid1=fork(); i+=2; if(!pid1) i++; if(i%3) pid2=fork(); if (pid2==0) { printf("sea \n "); i-=1; } if(i>=2)... (4 Replies)
Discussion started by: pfpietro
4 Replies
PTHREAD_ATFORK(3)					   BSD Library Functions Manual 					 PTHREAD_ATFORK(3)

NAME
pthread_atfork -- register handlers to be called before and after fork() SYNOPSIS
#include <pthread.h> int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); DESCRIPTION
The pthread_atfork() function is used to register functions to be called before and after fork(). The prepare handler is called before fork(), while the parent and child handlers are called after fork() in the parent and child process respectively. The prepare handlers are called in reverse order of their registration, while parent and child handlers are called in the order in which they were registered. Any of the handlers may be NULL. Important: only async-signal-safe functions are allowed on the child side of fork(). See sigaction(2) for details. RETURN VALUES
If successful, the pthread_atfork() function will return zero; otherwise an error number will be returned to indicate the error. ERRORS
pthread_atfork() will fail if: [ENOMEM] The system lacked the necessary resources to add another handler to the list. SEE ALSO
fork(2) STANDARDS
pthread_atfork() conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
August 12, 2004 BSD
All times are GMT -4. The time now is 05:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy