diff --git a/func.S b/func.S index 8d1ce22..05ae52d 100644 --- a/func.S +++ b/func.S @@ -17,7 +17,7 @@ errstr: .ascii "error happened\n" .set errstr_len, .-errstr -.set buffer_size, 1024 +.set buffer_size, 1024*1024 buffer: .skip buffer_size, 0 .text @@ -105,9 +105,7 @@ error: movq $errstr, %rsi movq $errstr_len, %rdx syscall -exit: + movq $__NR_exit, %rax - movq $0, %rdi - movq $0, %rsi + movq $2, %rdi syscall - movq $0, 0 diff --git a/main.S b/main.S index 73ae625..36fae61 100644 --- a/main.S +++ b/main.S @@ -8,7 +8,8 @@ #define PF_INET 2 #define AF_INET PF_INET -#define SOCK_STREAM 1 +#define SOCK_STREAM 1 +#define CLONE_PARENT 0x00008000 #define PORT 20335 @@ -100,8 +101,13 @@ loop: movq $message_len, %rdx call write_buf - movq $__NR_fork, %rax - syscall /* fork! */ + movq $__NR_clone, %rax + movq $CLONE_PARENT, %rdi + movq $0, %rsi + movq $0, %rdx + movq $0, %r10 + movq $0, %r8 + syscall /* fork! (through clone()) */ cmp $-1, %rax jz error test %rax, %rax @@ -135,7 +141,7 @@ error: syscall movq $__NR_exit, %rax - movq $0, %rdi + movq $1, %rdi syscall /* this line is unreachable */