summaryrefslogtreecommitdiffstats
path: root/man5/core.5
diff options
context:
space:
mode:
Diffstat (limited to 'man5/core.5')
-rw-r--r--man5/core.524
1 files changed, 12 insertions, 12 deletions
diff --git a/man5/core.5 b/man5/core.5
index 816712149..2b1c0f7ec 100644
--- a/man5/core.5
+++ b/man5/core.5
@@ -620,7 +620,7 @@ Total bytes in core dump: 282624
\&
.EX
/* core_pattern_pipe_test.c */
-
+\&
#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
@@ -628,9 +628,9 @@ Total bytes in core dump: 282624
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+\&
#define BUF_SIZE 1024
-
+\&
int
main(int argc, char *argv[])
{
@@ -638,33 +638,33 @@ main(int argc, char *argv[])
char buf[BUF_SIZE];
FILE *fp;
char cwd[PATH_MAX];
-
+\&
/* Change our current working directory to that of the
crashing process. */
-
+\&
snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
chdir(cwd);
-
+\&
/* Write output to file "core.info" in that directory. */
-
+\&
fp = fopen("core.info", "w+");
if (fp == NULL)
exit(EXIT_FAILURE);
-
+\&
/* Display command\-line arguments given to core_pattern
pipe program. */
-
+\&
fprintf(fp, "argc=%d\en", argc);
for (size_t j = 0; j < argc; j++)
fprintf(fp, "argc[%zu]=<%s>\en", j, argv[j]);
-
+\&
/* Count bytes in standard input (the core dump). */
-
+\&
tot = 0;
while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
tot += nread;
fprintf(fp, "Total bytes in core dump: %zd\en", tot);
-
+\&
fclose(fp);
exit(EXIT_SUCCESS);
}