2006-02-27 Robert Love <rml@novell.com>
* dispatcher-daemon/NetworkManagerDispatcher.c, src/NetworkManager.c: Open the pid file O_TRUNC, so if it already exists we truncate it to zero length. Also, be more verbose about warnings generated during writing out the pid file. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1508 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2006-02-27 Robert Love <rml@novell.com>
|
||||
|
||||
* dispatcher-daemon/NetworkManagerDispatcher.c, src/NetworkManager.c:
|
||||
Open the pid file O_TRUNC, so if it already exists we truncate it to
|
||||
zero length. Also, be more verbose about warnings generated during
|
||||
writing out the pid file.
|
||||
|
||||
2006-02-27 Robert Love <rml@novell.com>
|
||||
|
||||
Patch by R. Vinay <rvinay@novell.com>:
|
||||
|
@@ -280,19 +280,22 @@ static void nmd_print_usage (void)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
write_pidfile (const char *pidfile)
|
||||
{
|
||||
char pid[16];
|
||||
int fd;
|
||||
int ignored;
|
||||
char pid[16];
|
||||
|
||||
if ((fd = open (pidfile, O_CREAT | O_WRONLY, 00644)) < 0)
|
||||
return FALSE;
|
||||
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||
ignored = write (fd, pid, strlen (pid));
|
||||
close (fd);
|
||||
return TRUE;
|
||||
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0)
|
||||
{
|
||||
nm_warning ("Opening %s failed: %s", pidfile, strerror (errno));
|
||||
return;
|
||||
}
|
||||
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||
if (write (fd, pid, strlen (pid)) < 0)
|
||||
nm_warning ("Writing to %s failed: %s", pidfile, strerror (errno));
|
||||
if (close (fd))
|
||||
nm_warning ("Closing %s failed: %s", pidfile, strerror (errno));
|
||||
}
|
||||
|
||||
|
||||
@@ -365,11 +368,7 @@ int main (int argc, char *argv[])
|
||||
g_thread_init (NULL);
|
||||
|
||||
if (pidfile)
|
||||
{
|
||||
if (!write_pidfile (pidfile))
|
||||
nm_warning ("Couldn't write pid file %s! errno: %s", pidfile,
|
||||
strerror (errno));
|
||||
}
|
||||
write_pidfile (pidfile);
|
||||
|
||||
/* Connect to the NetworkManager dbus service and run the main loop */
|
||||
if ((connection = nmd_dbus_init ()))
|
||||
|
@@ -664,19 +664,22 @@ void nm_hal_deinit (NMData *data)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
write_pidfile (const char *pidfile)
|
||||
{
|
||||
char pid[16];
|
||||
int fd;
|
||||
int ignored;
|
||||
char pid[16];
|
||||
|
||||
if ((fd = open (pidfile, O_CREAT | O_WRONLY, 00644)) < 0)
|
||||
return FALSE;
|
||||
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||
ignored = write (fd, pid, strlen (pid));
|
||||
close (fd);
|
||||
return TRUE;
|
||||
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0)
|
||||
{
|
||||
nm_warning ("Opening %s failed: %s", pidfile, strerror (errno));
|
||||
return;
|
||||
}
|
||||
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||
if (write (fd, pid, strlen (pid)) < 0)
|
||||
nm_warning ("Writing to %s failed: %s", pidfile, strerror (errno));
|
||||
if (close (fd))
|
||||
nm_warning ("Closing %s failed: %s", pidfile, strerror (errno));
|
||||
}
|
||||
|
||||
|
||||
@@ -780,11 +783,7 @@ int main( int argc, char *argv[] )
|
||||
dbus_g_thread_init ();
|
||||
|
||||
if (pidfile)
|
||||
{
|
||||
if (!write_pidfile (pidfile))
|
||||
nm_warning ("Couldn't write pid file %s! errno: %s", pidfile,
|
||||
strerror (errno));
|
||||
}
|
||||
write_pidfile (pidfile);
|
||||
|
||||
nm_logging_setup (become_daemon);
|
||||
nm_info ("starting...");
|
||||
|
Reference in New Issue
Block a user