That code works fine for me. I compiled it with
gcc -o shell shell.c
ran it as
./shell
and it print the shellcode length and gave me a shell. Maybe you're on the wrong architecture or something.