shell - Gnu Assembler - using Fork() -


i want spawn shell e.g. /bin/sh.

so looked here: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html fork syscall number 2.

so code like:

.globl  _start  .text _start:     movl    **wtf-here?!?!** (how use pt_regs?), %ebx     movl    $2, %eax     int $0x80      movl    $0, %ebx     movl    $1, %eax     int $0x80 .data 

anybody idea?

afaik table state of registers on entry in kernel, not how call it

simply put syscall preserve ebx , ecx, , process syscall result follows:

    pushl  ebx          # registers preserve     pushl  ecx     movl    $2, %eax    # system call number fork.     int    $0x80        # call int     popl   ecx          # restore preserved regs.     popl   ebx     cmpl  $-4095,%eax   # int returning values between-4095..-1 -> error.     jb    .lsyscok     negl  %eax          # error. negate value.     call  seterrno      # call procedure sets errno in pic safe way.     movl  $-1,%eax      # set return value in case of error (exactly -1)  .lsyscok: 

read manpages how determine if in child or in parent. pay attention allowed in parent afterwards. note on bsd systems might want call rfork spawn processes.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -