File: mq_open.c

package info (click to toggle)
lsof 4.99.4%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,924 kB
  • sloc: ansic: 50,680; sh: 8,351; makefile: 1,194; perl: 940; awk: 214
file content (24 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <fcntl.h>    /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <mqueue.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>

#define NAME "/xxx"

static void do_nothing(int n) { signal(SIGCONT, do_nothing); }

int main(void) {
    mqd_t t = mq_open(NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
    if ((mqd_t)t == -1) {
        perror("open[" NAME "]");
        return 1;
    }

    printf("pid: %d / fd: %d\n", getpid(), t);
    fflush(stdout);
    signal(SIGCONT, do_nothing);
    pause();
    return 0;
}