No more zombies.
This commit is contained in:
parent
81e488e287
commit
8a8aab4f9b
8
func.S
8
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
|
||||
|
|
|
|||
14
main.S
14
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 */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user