unexpected behaviour of system function "system" in linux in some cases

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Any One can you explanation why this is happening .
In the below program
In some cases the system command is returning with -1 even the command
in the system call had succeded

To have a look i am attaching strace out put also
to be clear u can search for XX in the strace output from that point u
can make some thing .....




#include<signal.h>
#include <errno.h>
#include <wait.h>
#include <stdio.h>


void signalHandler(int i);
void thread1();

void thread1()
{
   while(1)
     sleep(1);
}

void main()
{
 int ret =-1;
 int res =-1;
 pthread_t th;

 res = pthread_create (&th, NULL, thread1, NULL);
 if (res)
 {
     printf ("pthread_create failed %d\n", res);
 }

 signal(SIGCHLD,signalHandler);
 ret = system("ls systembug.c");
 printf("XX the retval  %d errno %d \n",ret,errno);
}


void signalHandler(int signal)
{
   int stat = 0;
   int pid = 0;
   printf("Caught the signal \n");
   while ((pid = waitpid(-1, &stat, WNOHANG)) > 0)
   {
          printf("Child process exited \n");

   }
}


STRACE OUTPUT

3333  execve("./a.out", ["./a.out"], [/* 61 vars */]) = 0
3333  uname({sys="Linux", node="WS29P191", ...}) = 0
3333  brk(0)                            = 0x804a000
3333  open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
3333  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
3333  open("/etc/ld.so.cache", O_RDONLY) = 3
3333  fstat64(3, {st_mode=S_IFREG|0644, st_size10%6111, ...}) = 0
3333  old_mmap(NULL, 106111, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
3333  close(3)                          = 0
3333  open("/lib/tls/libpthread.so.0", O_RDONLY) = 3
3333  read(3,
"7ELF0I"..., 512) = 512
3333  fstat64(3, {st_mode=S_IFREG|0755, st_size88%272, ...}) = 0
3333  old_mmap(NULL, 65004, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40032000
3333  madvise(0x40032000, 65004, MADV_SEQUENTIAL|0x1) = 0
3333  old_mmap(0x4003f000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0xd000) = 0x4003f000
3333  old_mmap(0x40040000, 7660, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40040000
3333  close(3)                          = 0
3333  open("/lib/tls/libc.so.6", O_RDONLY) = 3
3333  read(3,
"7ELF@S0"..., 512) =
512
3333  fstat64(3, {st_mode=S_IFREG|0755, st_size13%45545, ...}) = 0
3333  old_mmap(NULL, 1128748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40042000
3333  madvise(0x40042000, 1128748, MADV_SEQUENTIAL|0x1) = 0
3333  old_mmap(0x4014b000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x109000) = 0x4014b000
3333  old_mmap(0x40153000, 10540, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40153000
3333  close(3)                          = 0
3333  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40156000
3333  set_thread_area({entry_number:-1 -> 6, base_addr:0x40156080,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
3333  munmap(0x40018000, 106111)        = 0
3333  set_tid_address(0x401560c8)       = 3333
3333  rt_sigaction(SIGRTMIN, {0x40036950, [], SA_SIGINFO}, NULL, 8) = 0
3333  rt_sigprocmask(SIG_UNBLOCK, [RTMIN], NULL, 8) = 0
3333  getrlimit(RLIMIT_STACK, {rlim_cur=RLIM_INFINITY,
rlim_max=RLIM_INFINITY}) = 0
3333  _sysctl({{CTL_KERN, KERN_VERSION}, 2, 0xbfffef28, 35, (nil), 0})
= 0
3333  mmap2(NULL, 2101248, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40157000
3333  brk(0)                            = 0x804a000
3333  brk(0x806b000)                    = 0x806b000
3333  brk(0)                            = 0x806b000
3333  mprotect(0x40157000, 4096, PROT_NONE) = 0
3333  clone(child_stack=0x40357b08,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
parent_tidptr=0x40357bf8, {entry_number:6, base_addr:0x40357bb0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1},
child_tidptr=0x40357bf8) = 3343
3333  rt_sigaction(SIGCHLD, {0x8048614, [CHLD], SA_RESTART}, ,
8) = 0
3333  rt_sigaction(SIGINT, , , 8) = 0
3333  rt_sigaction(SIGQUIT, , , 8) = 0
3343  rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
3343  rt_sigaction(SIGCHLD, NULL, {0x8048614, [CHLD], SA_RESTART}, 8) =
0
3343  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
3343  nanosleep({1, 0},  <unfinished ...>
3333  rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
3333  clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbffff024) = 3350
3333  waitpid(3350,  <unfinished ...>
3350  rt_sigaction(SIGINT, , NULL, 8) = 0
3350  rt_sigaction(SIGQUIT, , NULL, 8) = 0
3350  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
3350  execve("/bin/sh", ["sh", "-c", "ls systembug.c"], [/* 61 vars
*/]) = 0
3350  uname({sys="Linux", node="WS29P191", ...}) = 0
3350  brk(0)                            = 0x80bb000
3350  open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
3350  open("/etc/ld.so.cache", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size10%6111, ...}) = 0
3350  old_mmap(NULL, 106111, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
3350  close(3)                          = 0
3350  open("/lib/libreadline.so.4", O_RDONLY) = 3
3350  read(3,
"7ELF00"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size17%6736, ...}) = 0
3350  old_mmap(NULL, 178420, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40032000
3350  madvise(0x40032000, 178420, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x40059000, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x27000) = 0x40059000
3350  old_mmap(0x4005d000, 2292, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4005d000
3350  close(3)                          = 0
3350  open("/lib/libhistory.so.4", O_RDONLY) = 3
3350  read(3,
"7ELF@0"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size24%828, ...}) = 0
3350  old_mmap(NULL, 27568, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x4005e000
3350  madvise(0x4005e000, 27568, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x40064000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x5000) = 0x40064000
3350  close(3)                          = 0
3350  open("/lib/libncurses.so.5", O_RDONLY) = 3
3350  read(3,
"7ELF02"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size31%6468, ...}) = 0
3350  old_mmap(NULL, 280780, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40065000
3350  madvise(0x40065000, 280780, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x4009e000, 45056, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x38000) = 0x4009e000
3350  old_mmap(0x400a9000, 2252, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x400a9000
3350  close(3)                          = 0
3350  open("/lib/libdl.so.2", O_RDONLY) = 3
3350  read(3,
"7ELF`0"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size13%647, ...}) = 0
3350  old_mmap(NULL, 8628, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x400aa000
3350  madvise(0x400aa000, 8628, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x400ac000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x400ac000
3350  close(3)                          = 0
3350  open("/lib/tls/libc.so.6", O_RDONLY) = 3
3350  read(3,
"7ELF@S0"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size13%45545, ...}) = 0
3350  old_mmap(NULL, 1128748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x400ad000
3350  madvise(0x400ad000, 1128748, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x401b6000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x109000) = 0x401b6000
3350  old_mmap(0x401be000, 10540, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401be000
3350  close(3)                          = 0
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x401c1000
3350  set_thread_area({entry_number:-1 -> 6, base_addr:0x401c1640,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
3350  munmap(0x40018000, 106111)        = 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
3350  close(3)                          = 0
3350  brk(0)                            = 0x80bb000
3350  brk(0x80dc000)                    = 0x80dc000
3350  brk(0)                            = 0x80dc000
3350  open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1
ENOENT (No such file or directory)
3350  open("/usr/share/locale/locale.alias", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size25%28, ...}) = 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40018000
3350  read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
3350  read(3, "", 4096)                 = 0
3350  close(3)                          = 0
3350  munmap(0x40018000, 4096)          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION", O_RDONLY) =
-1 ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION", O_RDONLY) =
3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size36%5, ...}) = 0
3350  mmap2(NULL, 365, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
3350  close(3)                          = 0
3350  open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size21%512, ...}) = 0
3350  mmap2(NULL, 21512, PROT_READ, MAP_SHARED, 3, 0) = 0x40019000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MEASUREMENT", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MEASUREMENT", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size23%, ...}) = 0
3350  mmap2(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4001f000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_TELEPHONE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_TELEPHONE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size59%, ...}) = 0
3350  mmap2(NULL, 59, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40020000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_ADDRESS", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_ADDRESS", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size15%5, ...}) = 0
3350  mmap2(NULL, 155, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40021000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_NAME", O_RDONLY) = -1 ENOENT
(No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_NAME", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size77%, ...}) = 0
3350  mmap2(NULL, 77, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40022000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_PAPER", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_PAPER", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size34%, ...}) = 0
3350  mmap2(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40023000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MESSAGES", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MESSAGES", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFDIR|0755, st_size40%96, ...}) = 0
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES",
O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size52%, ...}) = 0
3350  mmap2(NULL, 52, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40024000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MONETARY", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MONETARY", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size28%6, ...}) = 0
3350  mmap2(NULL, 286, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40025000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_COLLATE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_COLLATE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size88%2134, ...}) = 0
3350  mmap2(NULL, 882134, PROT_READ, MAP_PRIVATE, 3, 0) = 0x401c2000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_TIME", O_RDONLY) = -1 ENOENT
(No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_TIME", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size24%51, ...}) = 0
3350  mmap2(NULL, 2451, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4029a000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_NUMERIC", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_NUMERIC", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size54%, ...}) = 0
3350  mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4029b000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_CTYPE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size20%8464, ...}) = 0
3350  mmap2(NULL, 208464, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4029c000
3350  close(3)                          = 0
3350  getuid32()                        = 8082
3350  getgid32()                        = 5003
3350  geteuid32()                       = 8082
3350  getegid32()                       = 5003
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  time(NULL)                        = 1145378591
3350  open("/etc/mtab", O_RDONLY)       = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size51%9, ...}) = 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x402cf000
3350  read(3, "/dev/sda2 / ext3 rw,acl,user_xat"..., 4096) = 519
3350  close(3)                          = 0
3350  munmap(0x402cf000, 4096)          = 0
3350  open("/proc/meminfo", O_RDONLY)   = 3
3350  fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x402cf000
3350  read(3, "MemTotal:      1033388 kB\nMemFre"..., 1024) = 644
3350  close(3)                          = 0
3350  munmap(0x402cf000, 4096)          = 0
3350  rt_sigaction(SIGCHLD, , , 8) = 0
3350  rt_sigaction(SIGCHLD, , , 8) = 0
3350  rt_sigaction(SIGINT, , , 8) = 0
3350  rt_sigaction(SIGINT, , , 8) = 0
3350  rt_sigaction(SIGQUIT, , , 8) = 0
3350  rt_sigaction(SIGQUIT, , , 8) = 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  rt_sigaction(SIGQUIT, , , 8) = 0
3350  uname({sys="Linux", node="WS29P191", ...}) = 0
3350  stat64("/home/g20230/tests", {st_mode=S_IFDIR|0775, st_size40%96,
...}) = 0
3350  stat64(".", {st_mode=S_IFDIR|0775, st_size40%96, ...}) = 0
3350  getpid()                          = 3350
3350  getppid()                         = 3333
3350  stat64(".", {st_mode=S_IFDIR|0775, st_size40%96, ...}) = 0
3350  stat64("/usr/local/bin/sh", 0xbfffe500) = -1 ENOENT (No such file
or directory)
3350  stat64("/usr/bin/sh", 0xbfffe500) = -1 ENOENT (No such file or
directory)
3350  stat64("/usr/X11R6/bin/sh", 0xbfffe500) = -1 ENOENT (No such file
or directory)
3350  stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size44%8312, ...}) =
0
3350  open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 3
3350  read(3, "65536\n", 31)            = 6
3350  close(3)                          = 0
3350  mmap2(NULL, 266240, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x402cf000
3350  getgroups32(65536, [5003])        = 1
3350  stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size44%8312, ...}) =
0
3350  getpgrp()                         = 3272
3350  rt_sigaction(SIGCHLD, {0x808da10, [], 0}, , 8) = 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
3350  stat64(".", {st_mode=S_IFDIR|0775, st_size40%96, ...}) = 0
3350  stat64("/usr/local/bin/ls", 0xbfffe320) = -1 ENOENT (No such file
or directory)
3350  stat64("/usr/bin/ls", 0xbfffe320) = -1 ENOENT (No such file or
directory)
3350  stat64("/usr/X11R6/bin/ls", 0xbfffe320) = -1 ENOENT (No such file
or directory)
3350  stat64("/bin/ls", {st_mode=S_IFREG|0755, st_size90%559, ...}) = 0
3350  stat64("/bin/ls", {st_mode=S_IFREG|0755, st_size90%559, ...}) = 0
3350  rt_sigaction(SIGINT, , , 8) = 0
3350  rt_sigaction(SIGQUIT, , , 8) = 0
3350  rt_sigaction(SIGCHLD, , {0x808da10, [], 0}, 8) = 0
3350  execve("/bin/ls", ["ls", "systembug.c"], [/* 61 vars */]) = 0
3350  uname({sys="Linux", node="WS29P191", ...}) = 0
3350  brk(0)                            = 0x805b000
3350  open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
3350  open("/etc/ld.so.cache", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size10%6111, ...}) = 0
3350  old_mmap(NULL, 106111, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
3350  close(3)                          = 0
3350  open("/lib/tls/librt.so.1", O_RDONLY) = 3
3350  read(3,
"7ELF"..., 512) = 512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size36%067, ...}) = 0
3350  old_mmap(NULL, 30684, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40032000
3350  madvise(0x40032000, 30684, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x40039000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x6000) = 0x40039000
3350  close(3)                          = 0
3350  open("/lib/libacl.so.1", O_RDONLY) = 3
3350  read(3,
"7ELF0"..., 512) = 512
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size31%632, ...}) = 0
3350  old_mmap(NULL, 20956, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x4003a000
3350  madvise(0x4003a000, 20956, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x4003f000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x5000) = 0x4003f000
3350  close(3)                          = 0
3350  open("/lib/libselinux.so.1", O_RDONLY) = 3
3350  read(3,
"7ELF03"..., 512) = 512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size61%336, ...}) = 0
3350  old_mmap(NULL, 57140, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40040000
3350  madvise(0x40040000, 57140, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x4004c000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0xb000) = 0x4004c000
3350  close(3)                          = 0
3350  open("/lib/tls/libc.so.6", O_RDONLY) = 3
3350  read(3,
"7ELF@S0"..., 512) =
512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size13%45545, ...}) = 0
3350  old_mmap(NULL, 1128748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x4004e000
3350  madvise(0x4004e000, 1128748, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x40157000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x109000) = 0x40157000
3350  old_mmap(0x4015f000, 10540, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4015f000
3350  close(3)                          = 0
3350  open("/lib/tls/libpthread.so.0", O_RDONLY) = 3
3350  read(3,
"7ELF0I"..., 512) = 512
3350  fstat64(3, {st_mode=S_IFREG|0755, st_size88%272, ...}) = 0
3350  old_mmap(NULL, 65004, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40162000
3350  madvise(0x40162000, 65004, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x4016f000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0xd000) = 0x4016f000
3350  old_mmap(0x40170000, 7660, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40170000
3350  close(3)                          = 0
3350  open("/lib/libattr.so.1", O_RDONLY) = 3
3350  read(3, "7ELF
\r0"..., 512) = 512
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size14%478, ...}) = 0
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40172000
3350  old_mmap(NULL, 13204, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40173000
3350  madvise(0x40173000, 13204, MADV_SEQUENTIAL|0x1) = 0
3350  old_mmap(0x40176000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x40176000
3350  close(3)                          = 0
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40177000
3350  set_thread_area({entry_number:-1 -> 6, base_addr:0x40177080,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
3350  munmap(0x40018000, 106111)        = 0
3350  set_tid_address(0x401770c8)       = 3350
3350  rt_sigaction(SIGRTMIN, {0x40166950, [], SA_SIGINFO}, NULL, 8) = 0
3350  rt_sigprocmask(SIG_UNBLOCK, [RTMIN], NULL, 8) = 0
3350  getrlimit(RLIMIT_STACK, {rlim_cur=RLIM_INFINITY,
rlim_max=RLIM_INFINITY}) = 0
3350  _sysctl({{CTL_KERN, KERN_VERSION}, 2, 0xbfffe6a8, 35, (nil), 0})
= 0
3350  open("/proc/mounts", O_RDONLY)    = 3
3350  brk(0)                            = 0x805b000
3350  brk(0x807d000)                    = 0x807d000
3350  read(3, "rootfs / rootfs rw 0 0\n/dev/root"..., 4095) = 622
3350  brk(0x807c000)                    = 0x807c000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1
ENOENT (No such file or directory)
3350  open("/usr/share/locale/locale.alias", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size25%28, ...}) = 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40018000
3350  read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
3350  read(3, "", 4096)                 = 0
3350  close(3)                          = 0
3350  munmap(0x40018000, 4096)          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION", O_RDONLY) =
-1 ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION", O_RDONLY) =
3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size36%5, ...}) = 0
3350  mmap2(NULL, 365, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
3350  close(3)                          = 0
3350  open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size21%512, ...}) = 0
3350  mmap2(NULL, 21512, PROT_READ, MAP_SHARED, 3, 0) = 0x40019000
3350  close(3)                          = 0
3350  futex(0x4015ee6c, FUTEX_WAKE, 2147483647) = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MEASUREMENT", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MEASUREMENT", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size23%, ...}) = 0
3350  mmap2(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4001f000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_TELEPHONE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_TELEPHONE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size59%, ...}) = 0
3350  mmap2(NULL, 59, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40020000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_ADDRESS", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_ADDRESS", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size15%5, ...}) = 0
3350  mmap2(NULL, 155, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40021000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_NAME", O_RDONLY) = -1 ENOENT
(No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_NAME", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size77%, ...}) = 0
3350  mmap2(NULL, 77, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40022000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_PAPER", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_PAPER", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size34%, ...}) = 0
3350  mmap2(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40023000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MESSAGES", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MESSAGES", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFDIR|0755, st_size40%96, ...}) = 0
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES",
O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size52%, ...}) = 0
3350  mmap2(NULL, 52, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40024000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_MONETARY", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_MONETARY", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size28%6, ...}) = 0
3350  mmap2(NULL, 286, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40025000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_COLLATE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_COLLATE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size88%2134, ...}) = 0
3350  mmap2(NULL, 882134, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40178000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_TIME", O_RDONLY) = -1 ENOENT
(No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_TIME", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size24%51, ...}) = 0
3350  mmap2(NULL, 2451, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40250000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_NUMERIC", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_NUMERIC", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size54%, ...}) = 0
3350  mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40251000
3350  close(3)                          = 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_CTYPE", O_RDONLY) = -1
ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY) = 3
3350  fstat64(3, {st_mode=S_IFREG|0644, st_size20%8464, ...}) = 0
3350  mmap2(NULL, 208464, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40252000
3350  close(3)                          = 0
3350  open("/proc/filesystems", O_RDONLY) = 3
3350  read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tb"..., 4095) = 253
3350  close(3)                          = 0
3350  ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig
-icanon -echo ...}) = 0
3350  ioctl(1, TIOCGWINSZ, {ws_row45%, ws_col12%6, ws_xpixel=0,
ws_ypixel=0}) = 0
3350  stat64("systembug.c", {st_mode=S_IFREG|0644, st_size68%4, ...}) =
0
3350  lstat64("systembug.c", {st_mode=S_IFREG|0644, st_size68%4, ...})
= 0
3350  socket(PF_UNIX, SOCK_STREAM, 0)   = 3
3350  connect(3, {sa_familyAF%_UNIX, path="/var/run/.nscd_socket"},
110) = 0
3350  writev(3, [", 12}, ", 5}], 2) =
17
3350  read(3,
"23"..., 36) = 36
3350  read(3, "g20230YyRPmwPoa433o/usr1/g202"..., 43) = 43
3350  close(3)                          = 0
3350  socket(PF_UNIX, SOCK_STREAM, 0)   = 3
3350  connect(3, {sa_familyAF%_UNIX, path="/var/run/.nscd_socket"},
110) = 0
3350  writev(3, [", 12}, ", 5}], 2) =
17
3350  read(3, "\n3",
24) = 24
3350  readv(3, [{"", 0}, ", 11}], 2) = 11
3350  read(3, NULL, 0)                  = 0
3350  close(3)                          = 0
3350  fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 16), ...})
= 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40285000
3350  write(1, "systembug.c\n", 12)     = 12
3350  munmap(0x40285000, 4096)          = 0
3350  exit_group(0)                     = ?
3343  <... nanosleep resumed> 0x403578d4) = ? ERESTART_RESTARTBLOCK (To
be restarted)
3343  --- SIGCHLD (Child exited) @ 0 (0) ---
3343  fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 16), ...})
= 0
3343  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40358000
3343  write(1, "Caught the signal \n", 19) = 19
3343  waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) =
3350
3343  write(1, "Child process exited \n", 22) = 22
3343  waitpid(-1, 0x403575c0, WNOHANG)  = 0
3343  sigreturn()                       = ? (mask now [])
3343  rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
3343  rt_sigaction(SIGCHLD, NULL, {0x8048614, [CHLD], SA_RESTART}, 8) =
0
3343  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
3343  nanosleep({1, 0},  <unfinished ...>
3333  <... waitpid resumed> 0xbffff020, 0) = -1 ECHILD (No child
processes)
3333  rt_sigaction(SIGINT, , NULL, 8) = 0
3333  rt_sigaction(SIGQUIT, , NULL, 8) = 0
3333  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
3333  write(1, "XX the retval  -1 errno 10 \n", 28) = 28
3333  munmap(0x40358000, 4096)          = 0
3333  exit_group(28)                    = ?
3343  <... nanosleep resumed> 0x403578d4) = ? ERESTART_RESTARTBLOCK (To
be restarted)


Re: unexpected behaviour of system function "system" in linux in some cases
Any One can you explanation why this is happening .
In the below program
In some cases the system command is returning with -1 even the command
in the system call had succeded

To have a look i am attaching strace out put also
to be clear u can search for XX in the strace output from that point u
can make some thing .....


you can compile with these flags

gcc -Wall -W -O2 systembug.c  -lpthread

Senario Explanation :

Actual behavior
system
thread 1
blocking of SIG_CHLD
(system())
waitpid()thread            ;
            ;            ........thread 2
            ;         childexit exit_group(0)
            ;
waitpid of system returned
 with child procees pid ...                  ;
                                                      ;
                                                      ;
                                                     thread3
                                         ------- signal handler
                                                 {
                                            while(waitpid(NOHUNG)>0)
(return with -1 and ECHILD)
                                                   {

                                                   }
                                            }
waitpid of system call returns success  with pid of the system call's
child process
After this signal handler was called and waitpid in the signal handler
returned with failure
(This is how i need but in some cases its works like below)


system
thread 1
blocking of SIG_CHLD
(system())
waitpid()thread
                        ........thread 2
                     childexit exit_group(0)            thread3
                                                         ------- signal
handler
                                                            {

while(waitpid(NOHUNG)>0)

 {
                                                                      }


}
waitpid of system call returns(with failure) because the waitpid in the
signal handler was returned with pid of the system call's child process

so the system calls wait pid will return with -1 and errno ECHILD





#include<signal.h>
#include <errno.h>
#include <wait.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>


void signalHandler(int i);
void *thread1(void *);

void *thread1(void *arg)
{

   while(1)
     sleep(1);

  return arg;
}

int main()
{
 int ret 3D%-1;
 int res 3D%-1;
 pthread_t th;

 res 3D% pthread_create (&th, NULL, thread1, NULL);
 if (res)
 {
     printf ("pthread_create failed %d\n", res);
 }

 signal(SIGCHLD,signalHandler);
 ret 3D% system("ls systembug.c");
 printf("XX the retval  %d errno %d \n",ret,errno);

 return 1;
}

void signalHandler(int signal)
{
   int stat 3D% 0;
   int pid 3D% 0;
   printf("Caught the signal \n");
   while ((pid 3D% waitpid(-1, &stat, WNOHANG)) > 0)
   {
          printf("Child process exited signum  %d\n",signal);
   }
}


STRACE OUTPUT

3333  execve("./a.out", ["./a.out"], [/* 61 vars */]) 3D% 0
3333  uname({sys3D%"Linux", node3D%"WS29P191", ...}) 3D% 0
3333  brk(0)                            3D% 0x804a000
3333  open("/etc/ld.so.preload", O_RDONLY) 3D% -1 ENOENT (No such file or

directory)
3333  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x40017000
3333  open("/etc/ld.so.cache", O_RDONLY) 3D% 3
3333  fstat64(3, {st_mode3D%S_IFREG|0644, st_size3D%106111, ...}) 3D% 0
3333  old_mmap(NULL, 106111, PROT_READ, MAP_PRIVATE, 3, 0) 3D% 0x40018000

3333  close(3)                          3D% 0
3333  open("/lib/tls/libpthread.so.0", O_RDONLY) 3D% 3
3333  read(3,
"7ELF0I"..., 512) 3D% 512

3333  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%88272, ...}) 3D% 0
3333  old_mmap(NULL, 65004, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%
0x40032000
3333  madvise(0x40032000, 65004, MADV_SEQUENTIAL|0x1) 3D% 0
3333  old_mmap(0x4003f000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0xd000) 3D% 0x4003f000
3333  old_mmap(0x40040000, 7660, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 3D% 0x40040000
3333  close(3)                          3D% 0
3333  open("/lib/tls/libc.so.6", O_RDONLY) 3D% 3
3333  read(3,
"7ELF@S0"..., 512) 3D%
512
3333  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%1345545, ...}) 3D% 0
3333  old_mmap(NULL, 1128748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%

0x40042000
3333  madvise(0x40042000, 1128748, MADV_SEQUENTIAL|0x1) 3D% 0
3333  old_mmap(0x4014b000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x109000) 3D% 0x4014b000
3333  old_mmap(0x40153000, 10540, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 3D% 0x40153000
3333  close(3)                          3D% 0
3333  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x40156000
3333  set_thread_area({entry_number:-1 -> 6, base_addr:0x40156080,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) 3D% 0
3333  munmap(0x40018000, 106111)        3D% 0
3333  set_tid_address(0x401560c8)       3D% 3333
3333  rt_sigaction(SIGRTMIN, {0x40036950, [], SA_SIGINFO}, NULL, 8) 3D% 0

3333  rt_sigprocmask(SIG_UNBLOCK, [RTMIN], NULL, 8) 3D% 0
3333  getrlimit(RLIMIT_STACK, {rlim_cur3D%RLIM_INFINITY,
rlim_max3D%RLIM_INFINITY}) 3D% 0
3333  _sysctl({{CTL_KERN, KERN_VERSION}, 2, 0xbfffef28, 35, (nil), 0})
3D% 0
3333  mmap2(NULL, 2101248, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x40157000
3333  brk(0)                            3D% 0x804a000
3333  brk(0x806b000)                    3D% 0x806b000
3333  brk(0)                            3D% 0x806b000
3333  mprotect(0x40157000, 4096, PROT_NONE) 3D% 0
3333  clone(child_stack3D%0x40357b08,
flags3D%CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSV=
SEAD%M|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,

parent_tidptr3D%0x40357bf8, {entry_number:6, base_addr:0x40357bb0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1},
child_tidptr3D%0x40357bf8) 3D% 3343
3333  rt_sigaction(SIGCHLD, {0x8048614, [CHLD], SA_RESTART}, ,

8) 3D% 0
3333  rt_sigaction(SIGINT, , , 8) 3D% 0
3333  rt_sigaction(SIGQUIT, , , 8) 3D% 0
3343  rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) 3D% 0
3343  rt_sigaction(SIGCHLD, NULL, {0x8048614, [CHLD], SA_RESTART}, 8) 3D%

0
3343  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) 3D% 0
3343  nanosleep({1, 0},  <unfinished ...>
3333  rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) 3D% 0
3333  clone(child_stack3D%0, flags3D%CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr3D%0xbffff024) 3D% 3350
3333  waitpid(3350,  <unfinished ...>
3350  rt_sigaction(SIGINT, , NULL, 8) 3D% 0
3350  rt_sigaction(SIGQUIT, , NULL, 8) 3D% 0
3350  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) 3D% 0
3350  execve("/bin/sh", ["sh", "-c", "ls systembug.c"], [/* 61 vars
*/]) 3D% 0
3350  uname({sys3D%"Linux", node3D%"WS29P191", ...}) 3D% 0
3350  brk(0)                            3D% 0x80bb000
3350  open("/etc/ld.so.preload", O_RDONLY) 3D% -1 ENOENT (No such file or

directory)
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x40017000
3350  open("/etc/ld.so.cache", O_RDONLY) 3D% 3
3350  fstat64(3, {st_mode3D%S_IFREG|0644, st_size3D%106111, ...}) 3D% 0
3350  old_mmap(NULL, 106111, PROT_READ, MAP_PRIVATE, 3, 0) 3D% 0x40018000

3350  close(3)                          3D% 0
3350  open("/lib/libreadline.so.4", O_RDONLY) 3D% 3
3350  read(3,
"7ELF00"..., 512) 3D%
512
3350  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%176736, ...}) 3D% 0
3350  old_mmap(NULL, 178420, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%
0x40032000
3350  madvise(0x40032000, 178420, MADV_SEQUENTIAL|0x1) 3D% 0
3350  old_mmap(0x40059000, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x27000) 3D% 0x40059000
3350  old_mmap(0x4005d000, 2292, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 3D% 0x4005d000
3350  close(3)                          3D% 0
3350  open("/lib/libhistory.so.4", O_RDONLY) 3D% 3
3350  read(3,
"7ELF@0"..., 512) 3D%
512
3350  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%24828, ...}) 3D% 0
3350  old_mmap(NULL, 27568, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%
0x4005e000
3350  madvise(0x4005e000, 27568, MADV_SEQUENTIAL|0x1) 3D% 0
3350  old_mmap(0x40064000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x5000) 3D% 0x40064000
3350  close(3)                          3D% 0
3350  open("/lib/libncurses.so.5", O_RDONLY) 3D% 3
3350  read(3,
"7ELF02"..., 512) 3D%
512
3350  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%316468, ...}) 3D% 0
3350  old_mmap(NULL, 280780, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%
0x40065000
3350  madvise(0x40065000, 280780, MADV_SEQUENTIAL|0x1) 3D% 0
3350  old_mmap(0x4009e000, 45056, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x38000) 3D% 0x4009e000
3350  old_mmap(0x400a9000, 2252, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 3D% 0x400a9000
3350  close(3)                          3D% 0
3350  open("/lib/libdl.so.2", O_RDONLY) 3D% 3
3350  read(3,
"7ELF`0"..., 512) 3D%
512
3350  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%13647, ...}) 3D% 0
3350  old_mmap(NULL, 8628, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%
0x400aa000
3350  madvise(0x400aa000, 8628, MADV_SEQUENTIAL|0x1) 3D% 0
3350  old_mmap(0x400ac000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x2000) 3D% 0x400ac000
3350  close(3)                          3D% 0
3350  open("/lib/tls/libc.so.6", O_RDONLY) 3D% 3
3350  read(3,
"7ELF@S0"..., 512) 3D%
512
3350  fstat64(3, {st_mode3D%S_IFREG|0755, st_size3D%1345545, ...}) 3D% 0
3350  old_mmap(NULL, 1128748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 3D%

0x400ad000
3350  madvise(0x400ad000, 1128748, MADV_SEQUENTIAL|0x1) 3D% 0
3350  old_mmap(0x401b6000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x109000) 3D% 0x401b6000
3350  old_mmap(0x401be000, 10540, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 3D% 0x401be000
3350  close(3)                          3D% 0
3350  old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x401c1000
3350  set_thread_area({entry_number:-1 -> 6, base_addr:0x401c1640,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) 3D% 0
3350  munmap(0x40018000, 106111)        3D% 0
3350  rt_sigprocmask(SIG_BLOCK, NULL, [], 8) 3D% 0
3350  open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) 3D% 3
3350  close(3)                          3D% 0
3350  brk(0)                            3D% 0x80bb000
3350  brk(0x80dc000)                    3D% 0x80dc000
3350  brk(0)                            3D% 0x80dc000
3350  open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) 3D% -1

ENOENT (No such file or directory)
3350  open("/usr/share/locale/locale.alias", O_RDONLY) 3D% 3
3350  fstat64(3, {st_mode3D%S_IFREG|0644, st_size3D%2528, ...}) 3D% 0
3350  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 3D% 0x40018000
3350  read(3, "# Locale name alias data base.\n#"..., 4096) 3D% 2528
3350  read(3, "", 4096)                 3D% 0
3350  close(3)                          3D% 0
3350  munmap(0x40018000, 4096)          3D% 0
3350  open("/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION", O_RDONLY) 3D%

-1 ENOENT (No such file or directory)
3350  open("/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION", O_RDONLY) 3D%
3
3350  fstat64(3, {st_mode3D%S_IFREG|0644, st_size3D%365, ...}) 3D% 0
3350  mmap2(NULL, 365, PROT_READ, MAP_PRIVATE, 3, 0) 3D% 0x40018000
3350  close(3)                          3D% 0
3350  open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) 3D% 3
3350  fstat64(3, {st_mode3D%S_IFREG|0644, st_size3D%21512, ...}) 3D% 0
3350  mmap2(NULL, 21512, PROT_READ, MAP_SHARED, 3, 0) 3D% 0x40019000
3350  close(3)                          3D%


Site Timeline