Postfix3.3.1
総合概要
データ構造
ファイル
ファイル一覧
大域各種
postfix-3.3.1
src
util
fifo_open.c
[詳解]
1
/*++
2
/* NAME
3
/* fifo_open 1
4
/* SUMMARY
5
/* fifo client test program
6
/* SYNOPSIS
7
/* fifo_open
8
/* DESCRIPTION
9
/* fifo_open creates a FIFO, then attempts to open it for writing
10
/* with non-blocking mode enabled. According to the POSIX standard
11
/* the open should succeed.
12
/* DIAGNOSTICS
13
/* Problems are reported to the standard error stream.
14
/* LICENSE
15
/* .ad
16
/* .fi
17
/* The Secure Mailer license must be distributed with this software.
18
/* AUTHOR(S)
19
/* Wietse Venema
20
/* IBM T.J. Watson Research
21
/* P.O. Box 704
22
/* Yorktown Heights, NY 10598, USA
23
/*--*/
24
25
#include <sys/stat.h>
26
#include <stdio.h>
27
#include <fcntl.h>
28
#include <signal.h>
29
#include <unistd.h>
30
#include <stdlib.h>
31
32
#define FIFO_PATH "test-fifo"
33
#define perrorexit(s) { perror(s); exit(1); }
34
35
static
void
cleanup(
void
)
36
{
37
printf(
"Removing fifo %s...\n"
,
FIFO_PATH
);
38
if
(unlink(
FIFO_PATH
))
39
perrorexit
(
"unlink"
);
40
printf(
"Done.\n"
);
41
}
42
43
static
void
stuck(
int
unused_sig)
44
{
45
printf(
"Non-blocking, write-only open of FIFO blocked\n"
);
46
cleanup();
47
exit(1);
48
}
49
50
int
main
(
int
unused_argc,
char
**unused_argv)
51
{
52
(void) unlink(
FIFO_PATH
);
53
printf(
"Creating fifo %s...\n"
,
FIFO_PATH
);
54
if
(mkfifo(
FIFO_PATH
, 0600) < 0)
55
perrorexit
(
"mkfifo"
);
56
signal(SIGALRM, stuck);
57
alarm(5);
58
printf(
"Opening fifo %s, non-blocking, write-only mode...\n"
,
FIFO_PATH
);
59
if
(open(
FIFO_PATH
, O_WRONLY | O_NONBLOCK, 0) < 0) {
60
perror(
"open"
);
61
cleanup();
62
exit(1);
63
}
64
printf(
"Non-blocking, write-only open of FIFO succeeded\n"
);
65
cleanup();
66
exit(0);
67
}
main
int main(int unused_argc, char **unused_argv)
Definition:
fifo_open.c:50
FIFO_PATH
#define FIFO_PATH
Definition:
fifo_open.c:32
perrorexit
#define perrorexit(s)
Definition:
fifo_open.c:33
2018年11月10日(土) 18時59分56秒作成 - Postfix3.3.1 / 構成:
1.8.9.1