[tuxdroid-svn] r295 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-04-28 09:27:16
|
Author: neimad Date: 2007-04-28 11:26:30 +0200 (Sat, 28 Apr 2007) New Revision: 295 Modified: daemon/trunk/libs/USBDaemon_pidfile.c Log: * Doxygenified comments. Modified: daemon/trunk/libs/USBDaemon_pidfile.c =================================================================== --- daemon/trunk/libs/USBDaemon_pidfile.c 2007-04-27 18:58:27 UTC (rev 294) +++ daemon/trunk/libs/USBDaemon_pidfile.c 2007-04-28 09:26:30 UTC (rev 295) @@ -1,4 +1,3 @@ - /* * Tux Droid - USB Daemon * Copyright (C) 2007 C2ME Sa <rem...@c2...> @@ -42,11 +41,10 @@ /************************************************************************ */ -/* read_pid +/** + * @brief Read the pid from the pid file. * - * Reads the specified pidfile and returns the read pid. - * 0 is returned if either there's no pidfile, it's empty - * or no pid can be read. + * @return 0 if either there's no pid file, it's empty or no pid can be read */ int read_pid(void) { @@ -62,11 +60,10 @@ return pid; } -/* check_pid +/** + * @brief Check existence of the process whose pid is in the pid file. * - * Reads the pid using read_pid and looks up the pid in the process - * table (using /proc) to determine if the process already exists. If - * so 1 is returned, otherwise 0. + * @return 1 if the process exists, 0 otherwise */ int check_pid(void) { @@ -76,22 +73,17 @@ if (!pid || pid == getpid()) return 0; - /* - * The 'standard' method of doing this is to try and do a 'fake' kill - * of the process. If an ESRCH error is returned the process cannot - * be found -- GW - */ - /* But... errno is usually changed only on error.. */ + /* Sending signal 0 sets errno to ESRCH if the process doesn't exist */ if (kill(pid, 0) && errno == ESRCH) return 0; return pid; } -/* write_pid +/** + * @brief Write the current process' pid to the pid file. * - * Writes the pid to the specified file. If that fails 0 is - * returned, otherwise the pid. + * @return Pid written if successful, 0 otherwise */ int write_pid(void) { @@ -136,10 +128,10 @@ return pid; } -/* remove_pid +/** + * @brief Delete the pid file. * - * Remove the the specified file. The result from unlink(2) - * is returned + * @return result from unkink(2) */ int remove_pid(void) { |