pidfiles again
Denis Vlasenko
vda.linux at googlemail.com
Mon Mar 26 15:56:22 PDT 2007
Hello Stephane,
Thanks for your efforts to improve busybox.
On Monday 26 March 2007 23:26, Stephane Billiart wrote:
> With the patch, people who don't need pidfiles at all, because they're
> using runsv or simply don't care can get a smaller busybox with no pidfile
> at all and those, like me, who want them can enable them so that crond
> and syslogd behave like the traditional versions.
+int writepidfile(const char *path)
+{
+ FILE *pidf;
+
+ pidf = fopen_or_warn(path, "w");
+ if (pidf) {
+ fprintf(pidf, "%u\n", getpid());
+ fclose(pidf);
+ return 0;
+ }
+ return 1;
+}
Can we avoid using stdio.h here? Pseudocode:
open();
full_write(itoa(getpid()) + "\n");
close();
But minor issues aside, let's take a look at this:
+#define removepidfile(f) remove_file(f, FILEUTILS_FORCE)
Please take a good look into remove_file() function body:
int remove_file(const char *path, int flags)
{
...
if (S_ISDIR(path_stat.st_mode)) {
...
if ((!(flags & FILEUTILS_FORCE) && access(path, W_OK) < 0 &&
isatty(0)) ||
(flags & FILEUTILS_INTERACTIVE)) {
fprintf(stderr, "%s: descend into directory '%s'? ", applet_name,
path);
if (!bb_ask_confirmation())
return 0;
What, syslogd will start talking to user? Daemonized syslogd???
[Well, not really, we try hard to prevent that by closing stdio,
but still... can we just unlink the pidfile?]
> The patch does not address udhcpc/udhcpd which still have a distinct
> pidfile writing code.
I recently touched it a bit, while trying to improve chances that
udhcp will work on NOMMU.
> Could this be merged in the trunk?
I would prefer another iteration. Start from attached patch...
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5.patch
Type: text/x-diff
Size: 4111 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070327/838b1f26/attachment.bin
More information about the busybox
mailing list