Re: vfork

Richard B. Johnson (root@chaos.analogic.com)
Wed, 10 Nov 1999 13:18:39 -0500 (EST)


On 10 Nov 1999, Kai Henningsen wrote:

[SNIPPED]
>
> Well, in 2.2.12 it seems strace can't follow vfork()s without some kernel
> patch. Or so I gather from the docs and the failure to perform.
>
> Is this better in 2.3.*?
>
> MfG Kai

Well, which task would you expect strace to follow after vfork() or
fork()?

Script started on Wed Nov 10 13:15:21 1999
# cat xxx.c
#include <stdio.h>
#include <unistd.h>
int main()
{
switch(fork())
{
case 0:
fprintf(stderr, "The kid\n");
for(;;) pause();
case -1:
exit(1);
default:
}
fprintf(stderr, "The parent exits\n");
return 0;
}
# gcc -o xxx xxx.c
# strace xxx
brk(0) = 0x804970c
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
mmap(0, 4096, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4000c000
munmap(0x4000c000, 4096) = 0
mmap(0, 644232, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4000c000
mprotect(0x40097000, 74888, PROT_NONE) = 0
mmap(0x40097000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x8b000) = 0x40097000
mmap(0x4009d000, 50312, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|0x20, 4294967295, 0) = 0x4009d000
close(3) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_WRITE) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_EXEC) = 0
SYS_136(0, 0x1, 0x4009c02c, 0xbffff79c, 0xbffff794) = 0
getpid() = 27891
fork() = 27892
The kid
write(2, "The parent exits\n", 17The parent exits
) = 17
_exit(0) = ?
# ps
PID TTY STAT TIME COMMAND
105 3 SW 0:00 (agetty)
106 4 SW 0:00 (agetty)
107 5 SW 0:00 (agetty)
108 6 SW 0:00 (agetty)
27167 2 S 0:00 -bash
27173 1 S 0:00 -bash
27779 1 S 0:00 pine
27878 2 S 0:00 script
27879 2 S 0:00 script
27880 p0 S 0:00 bash -i
27892 p0 S 0:00 xxx <<======== child still there
27895 p0 R 0:00 ps
# kill -TERM 27892
# exit
exit

Script done on Wed Nov 10 13:16:13 1999

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/