DragonFly submit List (threaded) for 2007-06
DragonFly BSD
DragonFly submit List (threaded) for 2007-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: VKERNEL Pidfile patch


From: Chris Turner <c.turner@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 17 Jun 2007 10:14:31 -0400

Joerg Sonnenberger wrote:
> On Sun, Jun 17, 2007 at 12:22:54AM -0400, Chris Turner wrote:
>>   - doing this 'inline' within the getopt processing. Felt this
>>     was simpleenough a task that that wasn't a big deal, but I
>>     can see how some might not like it that way.
> 
> How does this work if -p is specified more than once?
> You don't have to strdup optarg if you don't modify argv.
> 
> Joerg

Updated version:

 - only handles 1 pidfile, which is the last -p argument specified.
 - pidfile processing moved to function for clarity
 - non-strduping of optarg

Thanks,

  - Chris

Index: share/man/man7/vkernel.7
===================================================================
RCS file: /var/local/apps/dcvs/src/share/man/man7/vkernel.7,v
retrieving revision 1.18
diff -r1.18 vkernel.7
53a54
> .Op Fl p Ar file
151a153,155
> .It Fl p Ar file
> Specify a file in which to store the process ID. 
> A warning is issued if this file cannot be opened for writing.
Index: sys/platform/vkernel/platform/init.c
===================================================================
RCS file: /var/local/apps/dcvs/src/sys/platform/vkernel/platform/init.c,v
retrieving revision 1.39
diff -r1.39 init.c
109a110
> static void writepid(char *path);
125a127
> 	char *pidfile = NULL;
132c134
< 
---
> 	
141c143
< 	while ((c = getopt(ac, av, "c:svm:r:e:i:I:U")) != -1) {
---
> 	while ((c = getopt(ac, av, "c:svm:r:e:i:p:I:U")) != -1) {
202a205,207
> 		case 'p':
> 			pidfile = optarg;	
> 			break;
208a214
> 	writepid(pidfile);
1041a1048,1065
> writepid(char *path)
> {
> 	pid_t self = 0;
> 	FILE *pidfile = NULL;
> 
> 	self = getpid();
> 	pidfile = fopen(path, "w");
> 	if (pidfile) {
> 		fprintf(pidfile, "%ld\n", (long)self);
> 		fclose(pidfile);
> 	}
> 	else {
> 		perror("Warning: couldn't open pidfile");
> 	}
> }
> 
> static
> void


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]