1. do_fork() and i386 Register Conventions
Hello All:
I'm trying to determine how to access:
1) the executable file name,
2) the command line arguments
3) and if possible the environment variables
of a recently forked process/thread in the linux kernel.
I am using a linux kernel 2.5.43 with the Linux Trace Toolkit (LTT)
0.9.6pre2
patch, with the i386 architecture (AMD Athlon) target.
Using the very helpful Linux Kernel Cross Reference for
the 2.5.46 kernel (sans LTT patch), I've noticed that the code for
kernel_thread function in kernel/process.c
216 regs.ebx = (unsigned long) fn;
217 regs.edx = (unsigned long) arg;
So I thought that regs.ebx held a pointer to the name of the
executable
being forked, and regs.edx held a pointer to the command line
arguments
list. However, when I tried to take strlen((unsigned char *)
regs.ebx)
it failed (and in the redhat 7.3 boot sequence, that the message
scrolls
away pretty quickly).
Is ((unsigned char *) regs.ebx) a pointer to the executable name, if
so, is there some memory protection issue here?
Do I need to do something to get at the memory where it resides?
Regarding the command line arguments, is ((unsigned char **) regs.edx)
the command line arguments corresponding to the argv parameter, as in
int main(int argc, char **argv)?
If so, is there a safe way to figure out the number of command line
arguments?
Thanks:
Bill M. (last name witheld to prevent spamming)
2. Fatal error opening RPM database (followed by sig 11's)
3. Register conventions for SPARC
4. Network Server Installation
5. CALL FOR PAPERS for the O'REILLY OPEN SOURCE CONVENTION 2000
6. Can't compile ipv[46] with ipsec (2.5.69)
7. compaq ap400 onboard nic
8. LINUX CALL FOR PAPERS for the O'REILLY OPEN SOURCE CONVENTION 2001
9. linux alpha calling convention
10. PASCAL calling convention in C++
11. CALL FOR PAPERS for the O'REILLY OPEN SOURCE CONVENTION 2000