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"
|
errstr: .ascii "error happened\n"
|
||||||
.set errstr_len, .-errstr
|
.set errstr_len, .-errstr
|
||||||
|
|
||||||
.set buffer_size, 1024
|
.set buffer_size, 1024*1024
|
||||||
buffer: .skip buffer_size, 0
|
buffer: .skip buffer_size, 0
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
@ -105,9 +105,7 @@ error:
|
||||||
movq $errstr, %rsi
|
movq $errstr, %rsi
|
||||||
movq $errstr_len, %rdx
|
movq $errstr_len, %rdx
|
||||||
syscall
|
syscall
|
||||||
exit:
|
|
||||||
movq $__NR_exit, %rax
|
movq $__NR_exit, %rax
|
||||||
movq $0, %rdi
|
movq $2, %rdi
|
||||||
movq $0, %rsi
|
|
||||||
syscall
|
syscall
|
||||||
movq $0, 0
|
|
||||||
|
|
|
||||||
14
main.S
14
main.S
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
#define PF_INET 2
|
#define PF_INET 2
|
||||||
#define AF_INET PF_INET
|
#define AF_INET PF_INET
|
||||||
#define SOCK_STREAM 1
|
#define SOCK_STREAM 1
|
||||||
|
#define CLONE_PARENT 0x00008000
|
||||||
|
|
||||||
#define PORT 20335
|
#define PORT 20335
|
||||||
|
|
||||||
|
|
@ -100,8 +101,13 @@ loop:
|
||||||
movq $message_len, %rdx
|
movq $message_len, %rdx
|
||||||
call write_buf
|
call write_buf
|
||||||
|
|
||||||
movq $__NR_fork, %rax
|
movq $__NR_clone, %rax
|
||||||
syscall /* fork! */
|
movq $CLONE_PARENT, %rdi
|
||||||
|
movq $0, %rsi
|
||||||
|
movq $0, %rdx
|
||||||
|
movq $0, %r10
|
||||||
|
movq $0, %r8
|
||||||
|
syscall /* fork! (through clone()) */
|
||||||
cmp $-1, %rax
|
cmp $-1, %rax
|
||||||
jz error
|
jz error
|
||||||
test %rax, %rax
|
test %rax, %rax
|
||||||
|
|
@ -135,7 +141,7 @@ error:
|
||||||
syscall
|
syscall
|
||||||
|
|
||||||
movq $__NR_exit, %rax
|
movq $__NR_exit, %rax
|
||||||
movq $0, %rdi
|
movq $1, %rdi
|
||||||
syscall
|
syscall
|
||||||
/* this line is unreachable */
|
/* this line is unreachable */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user