ALT Linux Bugzilla
– Attachment 1702 Details for
Bug 10407
ugly initscript
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
pidfile creation patch
unfs3-0.9.16-alt.pidfile.patch (text/plain), 2.17 KB, created by
Nick S. Grechukh
on 2006-12-12 18:19:26 MSK
(
hide
)
Description:
pidfile creation patch
Filename:
MIME Type:
Creator:
Nick S. Grechukh
Created:
2006-12-12 18:19:26 MSK
Size:
2.17 KB
patch
obsolete
>Index: daemon.c >=================================================================== >--- daemon.c (revision 1) >+++ daemon.c (working copy) >@@ -25,7 +25,7 @@ > #include <syslog.h> > #include <time.h> > #include <unistd.h> >- >+#include <errno.h> > #if HAVE_RPC_SVC_SOC_H == 1 > # include <rpc/svc_soc.h> > #endif >@@ -54,6 +54,7 @@ > int opt_expire_writers = FALSE; > int opt_detach = TRUE; > char *opt_exports = "/etc/exports"; >+char *opt_pidfile = "/var/run/unfsd.pid"; > int opt_cluster = FALSE; > char *opt_cluster_path = "/"; > int opt_tcponly = FALSE; >@@ -114,7 +115,7 @@ > static void parse_options(int argc, char **argv) > { > int opt = 0; >- char *optstring = "bcC:de:hl:m:n:pstuw"; >+ char *optstring = "bcC:de:hl:m:n:pstuwi:"; > > while (opt != -1) { > opt = getopt(argc, argv, optstring); >@@ -210,6 +211,9 @@ > case '?': > exit(1); > break; >+ case 'i': >+ opt_pidfile = optarg; >+ break; > } > } > } >@@ -256,6 +260,12 @@ > > backend_shutdown(); > >+ // killpid >+ fprintf(stderr, "Deleting pidfile %s\n", opt_pidfile); // ok, if fork done this mesage goes to /dev/null >+ if (unlink(opt_pidfile) == -1) { >+ logmsg(LOG_EMERG,"Failed to delete pidfile"); >+ } >+ > exit(1); > } > >@@ -770,6 +780,21 @@ > /* no umask to not screw up create modes */ > umask(0); > >+ // pidfile always created here - by parent if !opt_detach or by child >+ int pid_fd = open(opt_pidfile, O_RDWR | O_CREAT, 0640); >+ if (pid_fd < 0) { >+ fprintf(stderr, "Failed to open pidfile %s: %s!\n", opt_pidfile, strerror(errno)); >+ exit(0); >+ } >+ if (lockf(pid_fd, F_TLOCK, 0) < 0) { >+ fprintf(stderr, "Failed to get a lock on pidfile %s: %s!\n", opt_pidfile, strerror(errno)); >+ exit(0); >+ } >+ char str[16]; >+ >+ snprintf(str, sizeof(str), "%d\n", getpid()); >+ write(pid_fd, str, strlen(str)); >+ > /* detach from terminal */ > if (opt_detach) { > setsid(); >Index: daemon.h >=================================================================== >--- daemon.h (revision 1) >+++ daemon.h (working copy) >@@ -33,6 +33,7 @@ > extern int opt_expire_writers; > extern int opt_detach; > extern char *opt_exports; >+extern char *opt_pidfile; > extern int opt_cluster; > extern char *opt_cluster_path; > extern int opt_singleuser;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 10407
: 1702 |
1703