discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gdomap problem creating pid file


From: Eric Christopherson
Subject: gdomap problem creating pid file
Date: Tue, 5 Aug 2003 17:12:07 -0500
User-agent: Mutt/1.5.4i

Hi all. I'm having some trouble getting gdomap to create a PID file when it
runs. Running it without the -I argument works fine, but if I run it with -I
/var/run/gdomap.pid it fails (silently, unless I specify -d). It also fails
when trying to write the pid file somewhere else, such as my home directory.
I have made sure the file does not exist before running gdomap.

I've debugged it to the best of my (admittedly inexperienced) ability, and
don't understand the results. Running strace on it (with the command line
parameters -I /home/eric/gdomap.pid -p -d -f) results in this at the very end:

  [...]
  getuid32()                              = 0
  open("/home/eric/gdomap.pid", O_RDONLY|O_CREAT|O_EXCL, 0644) = 5
  fcntl64(5, F_GETFL)                     = 0 (flags O_RDONLY)
  write(2, "Unable to create new pid file - "..., 55Unable to create new pid
  file - '/home/eric/gdomap.pid') = 55
  write(2, "\n", 1
  )                       = 1
  write(2, "exiting.\n", 9exiting.
  )               = 9
  exit_group(1)                           = ?

I didn't notice any tell-tale signs of what was going wrong there (although
now that I'm writing this, I wonder if the problem is with fdopen() trying
to make the file writeable when it was opened read-only?)

Running gdb:
  [...]
  (gdb) break gdomap.c:4579
  Breakpoint 1 at 0x8050365: file gdomap.c, line 4579.
  (gdb) run -I /home/eric/gdomap.pid -p -d -f
  Starting program:
  /site/home/eric/src/cvs/gnustep/core/base/Tools/shared_debug_obj/gdomap -I
  /home/eric/gdomap.pid -p -d -f
  [New Thread 16384 (LWP 12276)]
  Closed descriptors
  Opened UDP socket 3
  Opened TDP socket 4
  [Switching to Thread 16384 (LWP 12276)]

  Breakpoint 1, main (argc=6, argv=0xbffff594) at gdomap.c:4579
  4579              int   desc = open(pidfile, O_EXCL|O_CREAT, 0644);
  (gdb) next
  4580              fptr = fdopen(desc, "w");
  (gdb) print desc
  $1 = 5
  (gdb) next
  4582              if (fptr == 0)
  (gdb) print errno
  $2 = 22
  (gdb) print fptr
  $3 = (FILE *) 0x0
  (gdb) cont
  Continuing.
  Unable to create new pid file - '/home/eric/gdomap.pid'
  exiting.

  Program exited with code 01.

The value of errno after fptr = fdopen(desc, "w"); in line 4580 is 22 =
EINVAL. Since according to fdopen(3) "The fdopen function may also fail and
set errno for any of the errors specified for the routine fcntl(2).", I
looked up EINVAL in fcntl(2), which says "For F_DUPFD, arg is negative or
is greater than the maximum allowable value. For F_SETSIG, arg is not an
allowable signal number." But the only fcntl in the strace (actually
fcntl64) shows the command as F_GETFL. So what does EINVAL mean when using
F_GETFL?

By the way, I'm using Linux, kernel 2.4.21, GNU libc6 2.3.1 (Debian unstable
package version 2.3.1-17). Anyone able to help me figure this out?

-- 
Furrfu!         r a k k o  at  c h a r t e r  dot  n e t




reply via email to

[Prev in Thread] Current Thread [Next in Thread]