05-06-2008
Yeah, non-blocking I/O was what I used on the Echo server.
Thanks all for the support
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I don't follow what these are...
this is what my text says...
"When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies
2. Programming
Hi all, i need to execute a program from within my c++ code. This is no problem. system(), fork(), execxy(). But now i want to able to execute the program as another user as the parent process.
The whole thing is on solaris. I should be possible for both, users with no shell and no password... (1 Reply)
Discussion started by: heck
1 Replies
3. Programming
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies
4. Shell Programming and Scripting
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies
5. UNIX for Advanced & Expert Users
Hi, as I understand fork(), it makes a copy of the parent which becomes a child. But is there anyway to make three children for that one parent. So in other words, if I look up the getppid() of the children, I want them to have the same value??
Thanks in advance to any help! (1 Reply)
Discussion started by: MS_CC
1 Replies
6. UNIX for Advanced & Expert Users
Hi all,
I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts.
My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to... (4 Replies)
Discussion started by: mark007
4 Replies
7. Programming
i used function fork().
so i made two process.
parent process accepted socket fd and writing to shared memory.
then now. how can child process share parent's socket fd?
is this possible?
Thanks in advance (1 Reply)
Discussion started by: andrew.paul
1 Replies
8. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process.
2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies
9. Programming
Hi friends,
I have a small question regarding unix system call fork, I hope you will solve my problem. Here is the small program
$ cat fork1.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
int pid;
int x = 0;
x = x + 1;
pid = fork();
if(pid < 0)
{... (2 Replies)
Discussion started by: gabam
2 Replies
10. Shell Programming and Scripting
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
LEARN ABOUT X11R4
pthread_atfork
PTHREAD_ATFORK(3) Library Functions Manual PTHREAD_ATFORK(3)
NAME
pthread_atfork - register handlers to be called at fork(2) time
SYNOPSIS
#include <pthread.h>
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
DESCRIPTION
pthread_atfork registers handler functions to be called just before and just after a new process is created with fork(2). The prepare han-
dler will be called from the parent process, just before the new process is created. The parent handler will be called from the parent
process, just before fork(2) returns. The child handler will be called from the child process, just before fork(2) returns.
One or several of the three handlers prepare, parent and child can be given as NULL, meaning that no handler needs to be called at the cor-
responding point.
pthread_atfork can be called several times to install several sets of handlers. At fork(2) time, the prepare handlers are called in LIFO
order (last added with pthread_atfork, first called before fork), while the parent and child handlers are called in FIFO order (first
added, first called).
To understand the purpose of pthread_atfork, recall that fork(2) duplicates the whole memory space, including mutexes in their current
locking state, but only the calling thread: other threads are not running in the child process. The mutexes are not usable after the fork
and must be initialized with pthread_mutex_init in the child process. This is a limitation of the current implementation and might or
might not be present in future versions.
RETURN VALUE
pthread_atfork returns 0 on success and a non-zero error code on error.
ERRORS
ENOMEM insufficient memory available to register the handlers.
AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr>
SEE ALSO
fork(2), pthread_mutex_lock(3), pthread_mutex_unlock(3).
LinuxThreads PTHREAD_ATFORK(3)