Sponsored Content
Top Forums UNIX for Dummies Questions & Answers what is diff b/w wait3() and wait4() system call Post 302130045 by blowtorch on Friday 3rd of August 2007 01:01:20 AM
Old 08-03-2007
The difference between the wait3() and wait4() seems to be quite obvious. wait4() allows you to specify a pid to wait for. Of course, you can give various values in the pid field which will modify the behaviour of the function.
In other words, difference between wait3 and wait4 is similar to the difference between wait and waitpid.

The difference between wait and wait3 or waitpid and wait4 is that wait3 and wait4 accept an additional argument. This is the struct rusage, that returns a summary of the system resources used by the child process. According to the man page, the only resources currentlyu reported are the user time and system time used.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

2. Programming

c system call

How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies

3. Programming

wait4

hello again! i have the following code, int main() { struct rusage rusage; for(int i=0;i<100;i++) { pid=fork(); if(pid==0)execl("","",NULL); else if(pid>0) { wait4(pid,&status,0,&rusage); printf("%lu.%06lu\n",rusage.ru_utime.tv_sec,rusage.ru_utime.tv_usec); } else... (3 Replies)
Discussion started by: nicos
3 Replies

4. Solaris

diff b/w /etc/system and user profile..

Hi Everybody, Can somebody tell me the difference between /etc/system and user profile???? (2 Replies)
Discussion started by: tirupathiraju_t
2 Replies

5. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

6. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

7. Shell Programming and Scripting

Call single function multiple times diff set of parameters

Okay, not sure if it can be done, I would think it could be done and I'm just having a hard time with it. fun_close_wait(){ ipVar="${1} ${2}" portVar=`cat "${5}" | cut -d' ' -f 1` for ip in $ipVar do for port in $portVar do netstatVar=`netstat -n | grep... (4 Replies)
Discussion started by: cbo0485
4 Replies

8. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

9. Shell Programming and Scripting

System terminating diff command before job completed

I'm running diff at the command prompt against two very large text files (>1GB) and system kills the process and replys back "Terminated" after 15 seconds. I believe a system parameter needs to be adjusted but can't figure it out. I'm running Red Hat 4.1.2-46, 2.6.18-028stab089.1 Thanks... (4 Replies)
Discussion started by: azpetef
4 Replies

10. Shell Programming and Scripting

system call

Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035> poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies
wait3(3C)                                                  Standard C Library Functions                                                  wait3(3C)

NAME
wait3, wait4 - wait for process to terminate or stop SYNOPSIS
#include <sys/wait.h> #include <sys/time.h> #include <sys/resource.h> pid_t wait3(int *statusp, int options, struct rusage *rusage); pid_t wait4(pid_t pid, int *statusp, int options, struct rusage *rusage); DESCRIPTION
The wait3() function delays its caller until a signal is received or one of its child processes terminates or stops due to tracing. If any child process has died or stopped due to tracing and this has not already been reported, return is immediate, returning the process ID and status of one of those children. If that child process has died, it is discarded. If there are no children, -1 is returned immediately. If there are only running or stopped but reported children, the calling process is blocked. If statusp is not a null pointer, then on return from a successful wait3() call, the status of the child process is stored in the integer pointed to by statusp. *statusp indicates the cause of termination and other information about the terminated process in the following man- ner: o If the low-order 8 bits of *statusp are equal to 0177, the child process has stopped; the 8 bits higher up from the low-order 8 bits of *statusp contain the number of the signal that caused the process to stop. See signal.h(3HEAD). o If the low-order 8 bits of *statusp are non-zero and are not equal to 0177, the child process terminated due to a signal; the low- order 7 bits of *statusp contain the number of the signal that terminated the process. In addition, if the low-order seventh bit of *statusp (that is, bit 0200) is set, a ``core image'' of the process was produced; see signal.h(3HEAD). o Otherwise, the child process terminated due to an exit() call; the 8 bits higher up from the low-order 8 bits of *statusp contain the low-order 8 bits of the argument that the child process passed to exit(); see exit(2). The options argument is constructed from the bitwise inclusive OR of zero or more of the following flags, defined in <sys/wait.h>: WNOHANG Execution of the calling process is not suspended if status is not immediately available for any child process. WUNTRACED The status of any child processes that are stopped, and whose status has not yet been reported since they stopped, are also reported to the requesting process. If rusage is not a null pointer, a summary of the resources used by the terminated process and all its children is returned. Only the user time used and the system time used are currently available. They are returned in the ru_utime and ru_stime, members of the rusage struc- ture, respectively. When the WNOHANG option is specified and no processes have status to report, wait3() returns 0. The WNOHANG and WUNTRACED options may be combined by the bitwise OR operation of the two values. The wait4() function is an extended interface. With a pid argument of 0, it is equivalent to wait3(). If pid has a nonzero value, then wait4() returns status only for the indicated process ID, but not for any other child processes. The status can be evaluated using the macros defined by wait.h(3HEAD). RETURN VALUES
If wait3() or wait4() returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. Otherwise, -1 is returned and errno is set to indicate the error. If wait3() or wait4() return due to the delivery of a signal to the calling process, -1 is returned and errno is set to EINTR. If WNOHANG was set in options, it has at least one child process specified by pid for which status is not available, and status is not available for any process specified by pid, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. The wait3() and wait4() functions return 0 if WNOHANG is specified and there are no stopped or exited children, and return the process ID of the child process if they return due to a stopped or terminated child process. Otherwise, they return -1 and set errno to indicate the error. ERRORS
The wait3() and wait4() functions will fail and return immediately if: ECHILD The calling process has no existing unwaited-for child processes. EFAULT The statusp or rusage arguments point to an illegal address. EINTR The function was interrupted by a signal. The value of the location pointed to by statusp is undefined. EINVAL The value of options is not valid. The wait4() function may fail if: ECHILD The process specified by pid does not exist or is not a child of the calling process. The wait3()and wait4() functions will terminate prematurely, return -1, and set errno to EINTR upon the arrival of a signal whose SA_RESTART bit in its flags field is not set (see sigaction(2)). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
kill(1), exit(2), waitid(2), waitpid(3C), getrusage(3C), signal(3C), signal.h(3HEAD), wait(3C), wait.h(3HEAD), proc(4) NOTES
If a parent process terminates without waiting on its children, the initialization process (process ID = 1) inherits the children. The wait3() and wait4() functions are automatically restarted when a process receives a signal while awaiting termination of a child process, unless the SA_RESTART bit is not set in the flags for that signal. SunOS 5.10 3 Mar 1995 wait3(3C)
All times are GMT -4. The time now is 05:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy