-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkiller.c
More file actions
37 lines (34 loc) · 763 Bytes
/
Copy pathkiller.c
File metadata and controls
37 lines (34 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
void kill_it(void) {
char *command = "hdparm --direct -t /dev/sda";
fclose(stdout);
while (1) {
system(command);
}
}
int main(int argc, char *argv[]) {
int i;
int num_procs = atoi(argv[1]);
if (num_procs < 1) {
fprintf(stderr, "Give me a number from 1 to max int\n");
exit(1);
}
for (i = 0; i < num_procs; i++) {
pid_t pid;
pid = fork();
if (pid < 0) {
fprintf(stderr, "Could not create process %d\n", i + 1);
}
if (pid == 0) {
kill_it();
}
}
for (i = 0; i < num_procs; i++) {
wait(NULL);
}
return 0;
}