Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F799036
mmap_trunc_core.c
avg (Andriy Gapon)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
avg
Jan 20 2017, 12:58 PM
2017-01-20 12:58:52 (UTC+0)
Size
868 B
Referenced Files
None
Subscribers
None
mmap_trunc_core.c
View Options
#include
<sys/types.h>
#include
<sys/mman.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
static
const
int
SIZE
=
4096
;
int
main
(
int
argc
,
char
*
argv
[])
{
char
*
p
;
int
fd
;
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"usage: %s <file>
\n
"
,
argv
[
0
]);
return
(
1
);
}
fd
=
open
(
argv
[
1
],
O_CREAT
|
O_EXCL
|
O_RDWR
,
0660
);
if
(
fd
==
-1
)
{
perror
(
"open"
);
return
(
1
);
}
unlink
(
argv
[
1
]);
if
(
ftruncate
(
fd
,
SIZE
)
==
-1
)
{
perror
(
"ftruncate"
);
return
(
1
);
}
p
=
mmap
(
NULL
,
4
*
SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
0
);
if
(
p
==
MAP_FAILED
)
{
perror
(
"mmap"
);
return
(
1
);
}
abort
();
}
File Metadata
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
723846
Default Alt Text
mmap_trunc_core.c (868 B)
Attached To
Mode
D9233: don't abort writing of a core dump after EFAULT
Attached
Detach File
Event Timeline
Log In to Comment