Daemonizing death under FreeBSD

Brion Vibber brion@pobox.com
Tue, 21 Oct 2003 02:19:21 -0700


--Apple-Mail-12-373932164
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

On Tuesday, Oct 21, 2003, at 02:04 US/Pacific, Brion Vibber wrote:
> strace seems to have issues under 5.1, but I got a ktrace/kdump output 
> for "memcache -d" vs "memcache". Everything seems the same up to the 
> fork in the daemon version, after which it immediately exits.

(slaps head) of course it immediately exits! That's the process that, 
um, exits... Ok, for the curious, attached a ktrace -i so it actually 
looks at the forked process.

-- brion vibber (brion @ pobox.com)


--Apple-Mail-12-373932164
Content-Disposition: attachment;
	filename=kdump-dead-daemon.txt
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	x-unix-mode=0755;
	name="kdump-dead-daemon.txt"

 20665 ktrace   RET   ktrace 0
 20665 ktrace   CALL  execve(0xbfbffc9a,0xbfbffbb8,0xbfbffbc4)
 20665 ktrace   NAMI  "./memcached"
 20665 memcached RET   execve 0
 20665 memcached CALL  gettimeofday(0x80ad98c,0)
 20665 memcached RET   gettimeofday 0
 20665 memcached CALL  kqueue
 20665 memcached RET   kqueue 3
 20665 memcached CALL  readlink(0x80a7f1f,0xbfbffa90,0x3f)
 20665 memcached NAMI  "/etc/malloc.conf"
 20665 memcached RET   readlink -1 errno 2 No such file or directory
 20665 memcached CALL  issetugid
 20665 memcached RET   issetugid 0
 20665 memcached CALL  getuid
 20665 memcached RET   getuid 501/0x1f5
 20665 memcached CALL  getgid
 20665 memcached RET   getgid 501/0x1f5
 20665 memcached CALL  mmap(0,0x1000,0x3,0x1002,0xffffffff,0,0,0)
 20665 memcached RET   mmap 671793152/0x280ac000
 20665 memcached CALL  break(0x80bc000)
 20665 memcached RET   break 0
 20665 memcached CALL  break(0x80bd000)
 20665 memcached RET   break 0
 20665 memcached CALL  gettimeofday(0xbfbffb18,0)
 20665 memcached RET   gettimeofday 0
 20665 memcached CALL  break(0x84bd000)
 20665 memcached RET   break 0
 20665 memcached CALL  mmap(0,0x3000,0x3,0x1002,0xffffffff,0,0,0)
 20665 memcached RET   mmap 671797248/0x280ad000
 20665 memcached CALL  munmap(0x280ac000,0x1000)
 20665 memcached RET   munmap 0
 20665 memcached CALL  break(0x84be000)
 20665 memcached RET   break 0
 20665 memcached CALL  getuid
 20665 memcached RET   getuid 501/0x1f5
 20665 memcached CALL  geteuid
 20665 memcached RET   geteuid 501/0x1f5
 20665 memcached CALL  fork
 20665 memcached RET   fork 20666/0x50ba
 20665 memcached CALL  exit(0)
 20666 memcached RET   fork 0
 20666 memcached CALL  setsid
 20666 memcached RET   setsid 20666/0x50ba
 20666 memcached CALL  chdir(0x80a593b)
 20666 memcached NAMI  "/"
 20666 memcached RET   chdir 0
 20666 memcached CALL  open(0x80a4367,0x2,0)
 20666 memcached NAMI  "/dev/null"
 20666 memcached RET   open 3
 20666 memcached CALL  dup2(0x3,0)
 20666 memcached RET   dup2 0
 20666 memcached CALL  dup2(0x3,0x1)
 20666 memcached RET   dup2 1
 20666 memcached CALL  dup2(0x3,0x2)
 20666 memcached RET   dup2 2
 20666 memcached CALL  close(0x3)
 20666 memcached RET   close 0
 20666 memcached CALL  sigaction(0xd,0xbfbffb64,0)
 20666 memcached RET   sigaction 0
 20666 memcached CALL  socket(0x2,0x1,0)
 20666 memcached RET   socket 3
 20666 memcached CALL  fcntl(0x3,0x3,0)
 20666 memcached RET   fcntl 2
 20666 memcached CALL  fcntl(0x3,0x4,0x6)
 20666 memcached RET   fcntl 0
 20666 memcached CALL  setsockopt(0x3,0xffff,0x4,0xbfbffb1c,0x4)
 20666 memcached RET   setsockopt 0
 20666 memcached CALL  setsockopt(0x3,0xffff,0x8,0xbfbffb1c,0x4)
 20666 memcached RET   setsockopt 0
 20666 memcached CALL  setsockopt(0x3,0xffff,0x80,0xbfbffb10,0x8)
 20666 memcached RET   setsockopt 0
 20666 memcached CALL  bind(0x3,0xbfbffb20,0x10)
 20666 memcached RET   bind 0
 20666 memcached CALL  listen(0x3,0x400)
 20666 memcached RET   listen 0
 20666 memcached CALL  break(0x84bf000)
 20666 memcached RET   break 0
 20666 memcached CALL  break(0x84c0000)
 20666 memcached RET   break 0
 20666 memcached CALL  gettimeofday(0xbfbffae8,0)
 20666 memcached RET   gettimeofday 0
 20666 memcached CALL  gettimeofday(0xbfbffae8,0)
 20666 memcached RET   gettimeofday 0
 20666 memcached CALL  gettimeofday(0xbfbffb20,0)
 20666 memcached RET   gettimeofday 0
 20666 memcached CALL  gettimeofday(0xbfbffae0,0)
 20666 memcached RET   gettimeofday 0
 20666 memcached CALL  kevent(0x3,0x80bc000,0x1,0x80bc800,0x40,0xbfbffae0)
 20666 memcached RET   kevent -1 errno 9 Bad file descriptor
 20666 memcached CALL  write(0x2,0xbfbff330,0xb)
 20666 memcached GIO   fd 2 wrote 11 bytes
       "memcached: "
 20666 memcached RET   write 11/0xb
 20666 memcached CALL  write(0x2,0xbfbff350,0x6)
 20666 memcached GIO   fd 2 wrote 6 bytes
       "kevent"
 20666 memcached RET   write 6
 20666 memcached CALL  write(0x2,0x80a74a7,0x2)
 20666 memcached GIO   fd 2 wrote 2 bytes
       ": "
 20666 memcached RET   write 2
 20666 memcached CALL  write(0x2,0xbfbff330,0x14)
 20666 memcached GIO   fd 2 wrote 20 bytes
       "Bad file descriptor
       "
 20666 memcached RET   write 20/0x14
 20666 memcached CALL  exit(0)

--Apple-Mail-12-373932164--