2
* Copyright (C) 2002-2005 Novell/SUSE
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation, version 2 of the
15
#include <sys/types.h>
21
static int gotsigusr1;
28
int main(int argc, char *argv[])
31
const char *data="hello world";
38
fprintf(stderr, "usage: %s file\n",
43
if (signal(SIGUSR1, handler) == SIG_ERR){
44
fprintf(stderr, "FAIL: internal error signal failed - %s\n",
49
if (sigemptyset(&sigset) == -1) {
50
perror ("FAIL: nullifying sigset");
54
fd=open(argv[1], O_CREAT|O_EXCL|O_RDWR, S_IWUSR|S_IRUSR);
56
fprintf(stderr, "FAIL: create %s failed - %s\n",
62
if (ftruncate(fd, getpagesize()) == -1){
63
fprintf(stderr, "FAIL: ftruncate %s failed - %s\n",
68
mptr=mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
70
if (mptr == MAP_FAILED){
71
fprintf(stderr, "FAIL: mmap failed - %s\n",
79
(void)memcpy(mptr, data, strlen(data));
81
if (msync(mptr, strlen(data), MS_SYNC) == -1){
82
fprintf(stderr, "FAIL: msync failed - %s\n",
88
(void)lseek(fd, 0, SEEK_SET);
89
rc=read(fd, buf, strlen(data));
91
if (rc != strlen(data)){
92
fprintf(stderr, "FAIL: read failed - %s\n",
97
if (memcmp(buf, mptr, strlen(data)) != 0){
98
fprintf(stderr, "FAIL: read comparison failed\n");
105
(void)sigsuspend(&sigset);