<?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; wait</title>
	<atom:link href="https://www.emblogic.com/blog/tag/wait/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>
		<item>
		<title>Completed creating a new process using fork, how orphan process works, wait by parent till child exit</title>
		<link>https://www.emblogic.com/blog/09/completed-creating-a-new-process-using-fork-how-orphan-process-works-wait-by-parent-till-child-exit/</link>
		<comments>https://www.emblogic.com/blog/09/completed-creating-a-new-process-using-fork-how-orphan-process-works-wait-by-parent-till-child-exit/#comments</comments>
		<pubDate>Mon, 22 Sep 2014 13:03:41 +0000</pubDate>
		<dc:creator><![CDATA[Joon Vichitra]]></dc:creator>
				<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[ipc]]></category>
		<category><![CDATA[orphan]]></category>
		<category><![CDATA[parent child]]></category>
		<category><![CDATA[wait]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=11512</guid>
		<description><![CDATA[RCS file: fork.c,v Working file: fork.c head: 1.4 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 4;    selected revisions: 4 description: program to create a duplicate process using fork &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.4 date: 2014/09/18 17:37:44;  author: &#8230; <a href="https://www.emblogic.com/blog/09/completed-creating-a-new-process-using-fork-how-orphan-process-works-wait-by-parent-till-child-exit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: fork.c,v<br />
Working file: fork.c<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4;    selected revisions: 4<br />
description:<br />
program to create a duplicate process using fork<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2014/09/18 17:37:44;  author: root;  state: Exp;  lines: +2 -0<br />
print child and its parent id<br />
check that orphan process have 1 as a parent id<br />
use sleep command to make sure that child not become orphan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2014/09/18 17:34:40;  author: root;  state: Exp;  lines: +2 -2<br />
get pid of child<br />
print pid of parent<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2014/09/18 17:30:58;  author: root;  state: Exp;  lines: +11 -1<br />
create a child process using fork<br />
define the body of child and parent using if and else<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/09/18 17:27:22;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: fork2.c,v<br />
Working file: fork2.c<br />
head: 1.3<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 3;    selected revisions: 3<br />
description:<br />
use multiple fork to create more child and parent process<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2014/09/19 12:49:25;  author: root;  state: Exp;  lines: +5 -0<br />
*** empty log message ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2014/09/19 12:03:53;  author: root;  state: Exp;  lines: +2 -3<br />
create more process using multiple fork statement<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/09/19 11:11:06;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: orphan.c,v<br />
Working file: orphan.c<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4;    selected revisions: 4<br />
description:<br />
program to make a process orphan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2014/09/20 09:36:08;  author: root;  state: Exp;  lines: +4 -2<br />
make child orphan and verify with output<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2014/09/19 13:54:25;  author: root;  state: Exp;  lines: +19 -10<br />
use if else to notify when the child became orphan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2014/09/19 13:42:45;  author: root;  state: Exp;  lines: +4 -3<br />
get child id<br />
print parent id<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/09/19 13:16:57;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: wait.c,v<br />
Working file: wait.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;    selected revisions: 1<br />
description:<br />
parent will wait till the child exit()<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/09/20 14:26:58;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/09/completed-creating-a-new-process-using-fork-how-orphan-process-works-wait-by-parent-till-child-exit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
