Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<pthread.h>
- #include<sys/stat.h>
- #include<sys/types.h>
- #include<fcntl.h>
- #define BUFF_READ 1024;
- typedef struct t_arg{
- char *message;
- int line;
- } thread_arg;
- void *request_handler(void *t_arg);
- char *fifo = "/home/ubuntu/work/my_fifo";
- int main(void){
- mkfifo(fifo, 0666);
- int srv_fifo = open(fifo, O_RDONLY);
- char buff[1024];
- while(1){
- read(srv_fifo, buff, 1024);
- pthread_t thread;
- thread_arg arg;
- arg.message = "Testing";
- arg.line = 2001;
- pthread_create(&thread, NULL, request_handler, &arg);
- pthread_detach(thread);
- memset(buff, 0, sizeof(buff));
- }
- }
- void *request_handler(void *t_arg){
- thread_arg real_arg = *(thread_arg*)t_arg;
- printf("%d",real_arg.line);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement