Consider the following code:
writer.c
mkfifo(\"/tmp/myfifo\", 0660);
int fd = open(\"/tmp/myfifo\", O_WRONLY);
char *foo, *bar;
...
write(fd, foo
A separator is indeed one way to do this - and conveniently enough, C strings come with such a separator - the nul-terminator at the end of the string.
If you change your write()
calls so that they also write out the nul-terminator (note that sizeof(char)
is defined to be 1, so it can be left out):
write(fd, foo, strlen(foo) + 1);
write(fd, bar, strlen(bar) + 1);
You can then pick apart the strings after you read them in (you will still need to read them into one buffer and then break them apart, unless you read them a character at a time).