I'm trying to use pthreads to create two new processes which each use a file descriptor to either read or write from a pipe.
I have a main function which forks itself and executes the pthread creator using execl(). From there, I run pthreads to create two processes which each get a different end of a pipe. I then wait for the threads to finish, then keep doing other things.
Here's my code:
int createThreads(int fds[])
{
int retcd = OK; /* return code */
pthread_t talk1, talk2;
int ret1, ret2;
// Create both talk agent processes
ret1 = pthread_create(&talk1, NULL, talk, &fds[0]); // read
ret2 = pthread_create(&talk2, NULL, talk, &fds[1]); // write
// Wait for both processes to finish at the same time
pthread_join(talk1, NULL);
pthread_join(talk2, NULL);
return(retcd);
}
The talk function takes the file descriptor and does some stuff with it. The problem is, when I run ps -f u [username] I can't seem to see the two pthreads processes spawn. Is there something wrong with the syntax?