i have this function:
char code[] = \"\\xeb\\x19\\x31\\xc0\\x31\\xdb\\x31\\xd2\\x31\\xc9\\xb0\\x04\\xb3\\x01\\x59\\xb2\\x05\\xcd\\x80\\x31\\xc0\\xb0\\x01\\x3
By default gcc will compile applications as having nonexecutable stacks. What you're seeing is a segmentation violation because your stack is marked nonexecutable but you're trying to execute code on the stack. You can verify by running your application in gdb and checking where it dies, for instance:
=> 0x601060 : jmp 0x60107b
This is the entry point of your shellcode. To make it so it doesn't segfault, you can disable exectstack by doing the following:
gcc -z execstack source.c