diff --git a/mem2swap.c b/mem2swap.c --- a/mem2swap.c +++ b/mem2swap.c @@ -9,6 +9,7 @@ #include #include #include +#include #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; }