<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EmbLogic &#187; waiting for a process</title>
	<atom:link href="https://www.emblogic.com/blog/tag/waiting-for-a-process/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Tue, 03 Mar 2020 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>waiting for a process</title>
		<link>https://www.emblogic.com/blog/01/waiting-for-a-process/</link>
		<comments>https://www.emblogic.com/blog/01/waiting-for-a-process/#comments</comments>
		<pubDate>Fri, 15 Jan 2016 10:36:05 +0000</pubDate>
		<dc:creator><![CDATA[Ankur Garg]]></dc:creator>
				<category><![CDATA[Linux Internals and System Programming]]></category>
		<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>
		<category><![CDATA[c programming]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[wait]]></category>
		<category><![CDATA[waiting for a process]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=13160</guid>
		<description><![CDATA[Waiting For a Process ===================== - Sometime we would like to find out when a child process has finished. - It is needed for parent process to wait until the child finishes before continuing by calling wait. - It has &#8230; <a href="https://www.emblogic.com/blog/01/waiting-for-a-process/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Waiting For a Process<br />
=====================<br />
- Sometime we would like to find out when a child process has finished.<br />
- It is needed for parent process to wait until the child finishes before continuing by calling wait.<br />
- It has prototype :<br />
pid_t wait(int *stat_loc);<br />
- It is declared in header :<br />
#include&lt;sys/wait.h&gt;<br />
- It has a return type pid_t which is declared in header :<br />
#include&lt;sys/types.h&gt;<br />
- The wait system call causes a parent process to pause until one of its child processes is stopped.<br />
- The wait returns PID of child process which is terminated.<br />
- The status information determine the exit status of child process (i.e  value returned from main or passed to exit)<br />
- If stat_loc is not a null pointer, the status information will be written to location to which it points.<br />
- The status information can be determined by using macros defined in header sys/wait.h</p>
<p>Macro                                        Defination<br />
WIFEXITED(stat_val)          Nonzero if child terminated normally<br />
WEXITSTATUS(stat_val)    If WIFEXITED is nonzero, this returns child exit code</p>
<p>WIFSIGNALED(stat_val)    Nonzero if child is terminated on an uncaught signal<br />
WTERMSIG(stat_val)           If WIFSIGNALED is nonzero, this returns signal number</p>
<p>WIFSTOPPED(stat_val)       Nonzero if the child has stopped<br />
WSTOPSIG(stat_val)            If WIFSTOPPED is nonzero, this returns signal number</p>
<p>- The wait() is used when a result of process done by child is used by the parent for further processing.<br />
- For eg :-<br />
In a program child process write to file1 and parent has to read from (the written data of)file1.<br />
If the scheduler runs read() command of the parent process before the write() command of child process, it reads nothing.<br />
- So, wait() is used before read() statement in parent process to avoid the unnecessory error.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/01/waiting-for-a-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
