[Bash] Reading from Standard Input

To read from standard input in a Bash shell, use read. The following script reads content from stanard input and outputs the content:


# Uncomment this to use comma as a separator.
# IFS=","

read first second third
echo first=\"${first}\" second=\"${second}\" third=\"${third}\"

Read more of this post

Using Shared Memory in Linux Programming

Shared memory is one way for processes to share information with each other. In the Linux environment, there are two main ways of obtaining shared memory in C or C++. The first method uses shmget to obtain an ID for the shared memory segment, then using shmat to attach the segment to the address space of the calling process. The declaration of these methods are as follows:

int shmget(key_t key, size_t size, int shmflg);

void *shmat(int shmid, const void *shmaddr, int shmflg);

Read more of this post