--- a/mem2swap.c
+++ b/mem2swap.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
+#include <wait.h>
#define N 1000
@@ -29,6 +30,7 @@
int size = sizeof (*p);
int megs = DEFAULT_MEGS;
+ int pid;
if (argc == 2)
megs = atoi (argv[1]);
@@ -64,7 +66,17 @@
}
printf ("\n\n");
- execve ("/usr/bin/free", args, NULL);
- return EXIT_SUCCESS;
+ pid = fork ();
+ switch (pid) {
+ case 0:
+ execve ("/usr/bin/free", args, NULL);
+ case -1:
+ perror ("Fork Error");
+ return EXIT_FAILURE;
+ default:
+ wait (&pid);
+ }
+
+ return pid;
}