The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
wait ${!} risshanth Shell Programming and Scripting 2 06-06-2008 03:57 AM
wait / sleep what to use??? gkrishnag UNIX for Dummies Questions & Answers 1 09-19-2006 05:13 AM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 04:42 PM
I/O wait Problem unavb UNIX for Dummies Questions & Answers 5 02-09-2006 07:45 PM
86% CPU for wait big123456 UNIX for Advanced & Expert Users 3 11-04-2005 10:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2008
Puntino Puntino is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 30
About wait

Hi everyone

I'm novice at Unix programming and I hope to post this thread in the correct place.
I have the following doubts:
1 Suppose we have some processes which are B's children process and another process A which has no relation with B and its children.
Can A do wait () for a children of B even if A is not the parent in any way?
  #2 (permalink)  
Old 04-26-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
wait() simply returns the status of one of the terminated children. You can't specify which child to wait() for. The kernel won't accidently return the status of a terminated process belonging to some other parent. There is a waitpid() but it is an error to specify a non-child pid or a pid that does not exist at all.
  #3 (permalink)  
Old 04-26-2008
Puntino Puntino is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 30
So in a nutshell only the parent can wait for the children.
Is there a reason for this ?
Imagine you have a process which want to monitor the other process, the unique way is to be the parent of all them, just like init.
  #4 (permalink)  
Old 04-26-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
waiting consumes the zombie. If some other process did that the parent could not learn the exit status of its own children. For security, one user's process cannot affect another user's process. But if you own the process or you are root, you can check it. Try to use the kill system call to send signal zero to the process in question. Signal zero has no effect on the process. But the process must exist or the kill() system call will fail.
  #5 (permalink)  
Old 04-26-2008
ramen_noodle ramen_noodle is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 251
Sure. The reasoning of it is the entire design architecture
behind a session and process group. If you are not familiar with
these unix concepts programatically W.Richard Stevens
is an invaluable resource.
It sounds like you may be coming from a windows environment.

As Perderabo notes the ability for a process to wait
on another processes session or process group introduces
ineradicable security issues for unix and unix-alikes.
A threaded model is more easily adapted because of
shared address space.

My advice is to use threads if you are uncomfortable with the process paradigm.
  #6 (permalink)  
Old 04-27-2008
Puntino Puntino is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 30
Thank you too, ramen_noodle.
I have to learn how to manage the processes too, not only threads.
Bye
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0