Hi, i am using a named pipe for IPC on a Debian system. I will be sending some data as a set of strings from a bash script to a background running process written in C code.
The data i want to send is four strings eg accountid, firstname,surname, description. Currently i am sending the data as a char array separated by spaces from my bash script.
echo "accountid firstname surname description" >$pipe
In the background process i read the pipe data like this into char array 'datain'
res = read(pipe_fd, datain, BUFFER_SIZE);
then i am just iterating over the array looking for spaces
eg
char* p = datain;
char accountid[80];
char firstname[80];
// extract the accountid
while(p!='')
{
accountid = p;
++p;
}
++p;
while(p!='')
{
firstname = p;
++p;
}
etc....
This method seems a bit crude however my programming skills are not that good so i was wondering if there was a better strategy for transferring this set of data over a named pipe in Linux.
Thanks