diff options
author | Havoc Pennington <hp@redhat.com> | 2007-03-12 22:52:40 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2007-03-12 22:52:40 +0000 |
commit | 9362aac398e3f2ec680e30c61ebfcb1e407eff72 (patch) | |
tree | faeb94c89d680598d1a809f6a3d952910dd3c741 /dbus/dbus-sysdeps-util-unix.c | |
parent | cc0aea750cb03ffa6a9e94e493455920ab3e612b (diff) |
2007-03-11 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (do_close_stderr): fix C89 problem and
formatting problem
* Mostly fix the DBusPipe mess.
- put line break after function return types
- put space before parens
- do not pass structs around by value
- don't use dbus_strerror after calling supposedly cross-platform
api
- don't name pipe variables "fd"
- abstract special fd numbers like -1 and 1
Diffstat (limited to 'dbus/dbus-sysdeps-util-unix.c')
-rw-r--r-- | dbus/dbus-sysdeps-util-unix.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 5da57db4..5ffc90d9 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -61,13 +61,13 @@ * Does the chdir, fork, setsid, etc. to become a daemon process. * * @param pidfile #NULL, or pidfile to create - * @param print_pid_fd file descriptor to print daemon's pid to, or -1 for none + * @param print_pid_pipe pipe to print daemon's pid to, or -1 for none * @param error return location for errors * @returns #FALSE on failure */ dbus_bool_t _dbus_become_daemon (const DBusString *pidfile, - DBusPipe print_pid_fd, + DBusPipe *print_pid_pipe, DBusError *error) { const char *s; @@ -135,7 +135,7 @@ _dbus_become_daemon (const DBusString *pidfile, } /* Write PID if requested */ - if (_dbus_pipe_is_valid(print_pid_fd)) + if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe)) { DBusString pid; int bytes; @@ -157,11 +157,14 @@ _dbus_become_daemon (const DBusString *pidfile, } bytes = _dbus_string_get_length (&pid); - if (_dbus_pipe_write (print_pid_fd, &pid, 0, bytes) != bytes) + if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes) { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Printing message bus PID: %s\n", - _dbus_strerror (errno)); + /* _dbus_pipe_write sets error only on failure, not short write */ + if (error != NULL && !dbus_error_is_set(error)) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "Printing message bus PID: did not write enough bytes\n"); + } _dbus_string_free (&pid); kill (child_pid, SIGTERM); return FALSE; |