I am working with ipc functions in linux such as pipe()
well I have a program that must be used in a loop and a pipe is used in
this program but when I use this program in aloop program never ends I think
it is because of the fork function that is located in the program but I don't know
how to control them I used free function but nothing happened and the program was in
error.
so how can I kill a process like that and is it a good way to control them?
here I have written a sample code that works
only for one time I mean if I ommit the line exit(EXIT_SUCCESS) in default part the activity of
client never ends with the wrong output it means that only it printfs:
child: the name is %s !!
for unlimited times but when I use this line every thing is ok but just for one data just for
"afi" in array names and then every thing ends.
well what do you think about it ? what is my problem?
i assume you had missed out /usr/include/signal.h by mistake
Quote:
but when I use this line every thing is ok but just for one data just for "afi" in array names and then every thing ends.
by the flow of the program what output you are getting is correct,
you have an exit(EXIT_SUCCESS);
in parent process hence after reaching at that point execution of the parent is terminated.
By this time you have only one value written to the pipe by the parent to be read by the child and parent terminates.
Hence the one vaue ( the string that is printed ) "afi"
is read from the pipe and printed by the child.
you can verify this by,
run the program and check for the binary you are running ps -ef | grep <binary_name>
once the parent is terminated , INIT process would adopt the child which is left without its parent (this can be verified with current PPID of the child as 1)
Quote:
the activity of client never ends with the wrong output it means that only it printfs:
child: the name is %s !!
for unlimited times
you had closed the read end of the pipe in parent as the parent is going to flush the data and not read -- close(fd[0])
after writing the first data even the write descriptor of the parent's pipe is closed. -- close(fd[1])
you can check this,
retval=write(fd[1],names[i],1024);
for the first time you would receive positive value indicating SUCCESS
and for subsequent writes a negative value indicating FAILURE
Hi all,
i developed a script to measure the uptime of a process in a Solaris 10/11 environments.
All is well, but i came across a situation where there are multiple processes of the same name. Basically i have the following result file:
beVWARS 13357 19592122
beVWARS 14329 19591910... (4 Replies)
Hi,
I want to read file multiple times. Right now i am using while loop but that is not working.
ex.
While read line
do
while read line2
do
echo stmt1
#processing some data based on data.,
done < file2.txt
done < file1.txt # This will have 10... (4 Replies)
Hi guys,
I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file
for eg:
file 1:
xx|yy|"xyz|zzz"|zzz|12...
using below awk command
awk 'BEGIN {FS=OFS="|" } print $3
i would get xyz
But i want as :
xyz|zzz to consider as whole column... (13 Replies)
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Hi Im running this script, which is supposed to find the max value build some tables and then stop running once all the tables are built. Thing is , it keeps assigning a null value to $h and then $g is null so it keep building tables i.e. testupdateNUL. How can I stop this? Here is what I have:
... (4 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)