Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    sys_fork arguments

    What is the meaning of the struct pt_regs argument to sys_fork? (This seems like a trivial question, but I've had no luck finding the answer, in the source code or otherwise.)

  2. #2
    From '/usr/include/asm/ptrace.h':

    /* this struct defines the way the registers are stored on the 
       stack during a system call. */
    struct pt_regs {
        long ebx;
        long ecx;
        long edx;
        long esi;
        long edi;
        long ebp;
        long eax;
        int  xds;
        int  xes;
        long orig_eax;
        long eip;
        int  xcs;
        long eflags;
        long esp;
        int  xss;

  3. #3
    I'm familiar with the definition of the structure; it contains a set of registers. My question is what it means to sys_fork.

  4. $spacer_open
  5. #4
    Oh, sorry...

    Try this:

    man ptrace

  6. #5
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    With pt_regs you have the __NR_number (the sys_call_table index) and the parameters passed to the syscall (eax, ebx, ecx... in order).

    As previously said, it is useful for tracing and debugging.

    Best regards!

  7. #6
    I am wondering how could I call sys_fork() with appropriate in how do i contruct the parameter to be passed?


  8. #7
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    You can't or better, you should not.

    It is a syscall that means that it is an interface between user space and kernel space. The compiler put the proper values into the registers, so when you make a fork() in user space, it calls to system_call assembler routine by means of the int 0x80 (and in modern processors and kernels with the SYSENTER instruction provided by Intel)

    So there is not need to put any values by hand.

    Best Regards

  9. #8
    Thanks a lot..I decided not to call it inside the kernel...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts