Replace C instructions for system calls

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Modify the program exec_in.c to obtain the same result but replacing the functions sleep and system for system calls. You can use exit, exec*, pause, alarm, etc. The new program will be called exec_in2.c and keep the original program syntax

  1. Relevant commands, code, scripts, algorithms:
#include <stdlib.h>  
#include <stdio.h>  
#include <string.h>  
#include <errno.h>  
#include <unistd.h>   
#include "rutines.h"  

 int main(int argc, char *argv[])  
{      
      char cmd[256];
      int a;

      if (argc<2)
          Error("Insufficient arguments: exec_in <sec> <cmd> [args...]");

     sleep(atoi(argv[1]));
     cmd[0]='\0';

     for(a=2;a<argc;a++)
     {
          strcat(cmd,argv[a]);
          strcat(cmd," ");
      }

     system(cmd);
     exit(0);
}
  1. The attempts at a solution (include all code and scripts):

I'm not sure what system call I need to solve the problem, I think that I need to use alarm but I don't know how to use correctly that, I never used system calls in C before, also I have only been using linux one week and I'm really lost.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course): Centre d'estudis Roca, Barcelona, Spain, Mariano Torres

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

I use ubuntu 12.04 64 bits

The first place too look would be the man pages. System calls are in section 2 - e.g. man 2 alarm (or look on this web site - http://www.unix.com/man-page/linux/2/alarm/\).

execl would probably be the system call you want.

Thanks Corona I will search about that.