Q:

use SIGQUIT and SIGINT

I'm trying to solve a problem because I'm learning to use system calls in C. I used a Ubuntu 12.04 64bit. 
The statement of the problem says that I need to implement a code that allows to execute a command (cmd2) after the correct end of other command (cmd1). Also says that user can specify both commands and all of the arguments that user wants. 
At this point I create this little program:
#include <syscall.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) 
{
    int cmd1 = system("sleep 5");

    if((cmd1 = (-1)))
    {
        write(1,"error in command 1",18);
    }
    if(cmd1=(0))
    {
        write(1, "hello world", 11);
    }
    return EXIT_SUCCESS;
}

Next, statement says that if the first command doesn't finish correctly the second will not execute, also, user can abort the execution of the cmd1 using Ctrl+\ or Ctrl+4 (SIGQUIT) and the second command (cmd2) using Ctrl+C (SIGINT). If second command is canceled the first must be completed normaly. 
I have problems in this second part of the statement because I never used this kind of things in C and also I'm really noob in linux. I tried to read something about SIGQUIT and SIGINT but I don't understand all that I've read probably because there are a lot of things of linux that I've not learned yet. 
Can anyone help me please?
Thanks!
I edit the code for this version using if functions. It doesn't work correctly, I'm finding how to check if the first command finishes correctly.

A:

Just to get you started. Let me explain the question because I feel you haven't understood it.

The statement of the problem says that I need to implement a code that allows to execute a command (cmd2) after the correct end of other command (cmd1).

You will will be given two commands by the user cmd1 and cmd2. cmd1 should be executed first.

Next, statement says that if the first command doesn't finish correctly the second will not execute, 

ONLY IF cmd1 finished executing normally should cmd2 be executed.

If second command is canceled the first must be completed normaly. 

Execution of cmd1 is not dependent on cmd2.

user can abort the execution of the cmd1 using Ctrl+\ or Ctrl+4 (SIGQUIT) 

You seem confused here. Here, they mean to say, cmd1 can be abnormally terminated by passing SIGQUIT to it(Ctrl+\ or Ctrl+4), in which case cmd2 should not be executed. You do NOT have to code the signals part. What you have to do is, check how cmd1 was terminated and then execute cmd2 if it was a normal termination else don't execute cmd2.
Note The code in the question was extremely different when the above part was posted.

This was your code on 5:02 AM Wednesday, 20 May 2015 GMT.(Had to include this because you are changing the code too often and too much)
int main(void) 
{
    int cmd1 = system("sleep 5");
    if((cmd1 = (-1)))
    {
        write(1,"error in command 1",18);
    }
    if(cmd1=(0))
    {
        write(1, "hello world", 11);
    }
    return EXIT_SUCCESS;
}

Here you are using = for comparing. = is used for assignment and not equality compassion. == is used for equality compassion. So, if((cmd1 = (-1))) and if(cmd1=(0)) should have been if((cmd1 == (-1))) and if(cmd1 == (0))
You are checking if the returned value is -1 for failure. This is incorrect. Exit code for success is 0 for failure is any value other than 0. So, if((cmd1 = (-1))) should have been if(cmd1 != 0).

