aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <JozanLeClerc@noemail.net>2020-11-20 17:49:30 +0000
committerJozanLeClerc <JozanLeClerc@noemail.net>2020-11-20 17:49:30 +0000
commit040a73a8e3763954320f36e1ac98e73ea0bb76f1 (patch)
tree64e0f463cd0e6ae3207a4406dc2ec9498965a0d6 /src
parentErrors I do not understand (diff)
downloadbsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.gz
bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.bz2
bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.xz
bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.zst
bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.zip
In progress
FossilOrigin-Name: 541eb5074479979fbad29b2df18964971000b067
Diffstat (limited to 'src')
-rw-r--r--src/c_bsdsetsid.S31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S
index b0027f9..7e1c6ae 100644
--- a/src/c_bsdsetsid.S
+++ b/src/c_bsdsetsid.S
@@ -45,6 +45,9 @@
* This is the entrypoint of the program.
*/
+.data
+status: .space 4, 0x0
+
.text
.globl main
@@ -53,42 +56,44 @@ main:
jle e_noarg
xor %rax, %rax
movb $0x2, %al
+ push %rdi
+ push %rsi
+ push %rdx
syscall
- jc e_fork
- cmp $0x0, %rax
- je c_child
+ test %rax, %rax
+ js e_fork
+ jz c_child
c_parent:
mov %rax, %rdi
-# xor %r8, %r8
-# lea (%r8), %rsi
+ lea status, %rsi
mov $0x0, %rdx
mov $0x0, %rcx
xor %rax, %rax
movb $0x7, %al /* SYS_wait4 */
syscall
-
xor %rdi, %rdi
- movb %al, %dil
+ lea (%rsi), %rdi
movb $0x7, %al
xor %rax, %rax
movb $0x1, %al /* SYS_exit */
syscall
c_child:
-# xor %rax, %rax
-# movb $0x93, %al /* SYS_setsid */
-# syscall
-# jc e_setsid
xor %rax, %rax
- push %rsi
+ movb $0x93, %al /* SYS_setsid */
+ syscall
+ jc e_setsid
+ xor %rax, %rax
+ pop %rdx
+ pop %rsi
+ pop %rdi
mov $0x1, %rcx
mov (%rsi, %rcx, 8), %rdi
lea 0(%rsi, %rcx, 8), %rsi
movb $0x3b, %al /* SYS_execve */
syscall
jc e_execve
- pop %rsi
jmp c_exit
c_exit: