File: get.c

package info (click to toggle)
fakeroot 0.0-17
  • links: PTS
  • area: main
  • in suites: slink
  • size: 160 kB
  • ctags: 189
  • sloc: ansic: 690; cpp: 543; makefile: 126; sh: 68
file content (25 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <errno.h>
#include "fakeroot.h"
/* ipc documentation bugs: msgsnd(2): MSGMAX=4056, not 4080 
   (def in ./linux/msg.h, couldn't find other def in /usr/include*  */

void main(int argc, char **argv){
  int msg;
  key_t key;
  struct my_msgbuf buf;
  int r=0;
  key=ftok("./get", FAKE_PROJ);
  
  msg=msgget(key,IPC_CREAT|0600);
  printf("msg=%i, key=%i\n",msg,key);
  do{
    r=msgrcv(msg,&buf,MAXMSG,0,0);
    printf("r=%i, recieved message type=%li, message=%s\n",r,buf.mtype, buf.mtext);
  }while ((r!=-1)||(errno==EINTR));
  perror("get");
  printf("r=%i, EINTR=%i\n",errno,EINTR);
}