Skip to content
Permalink
ebbe202c21
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (33 sloc) 567 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void usage(char **argv) {
fprintf(stderr, "usage: %s size\n", argv[0]);
exit(1);
}
volatile char c;
int main(int argc, char **argv) {
if (argc != 2)
usage(argv);
size_t size = atol(argv[1]);
char *data = malloc(size);
if (!data) {
perror("malloc");
exit(1);
}
for (long unsigned i=0;i<size;i++) {
volatile char *p = &data[i];
*p = 1;
c = *p;
}
pid_t pid = fork();
if (pid == 0) {
sleep(120);
exit(0);
}
if (pid == -1) {
perror("fork");
exit(1);
}
sleep(120);
}