Index: src/ipmievd.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/src/ipmievd.c,v
retrieving revision 1.35
diff -c -r1.35 ipmievd.c
*** src/ipmievd.c	2 Oct 2009 14:30:45 -0000	1.35
--- src/ipmievd.c	22 Jan 2012 19:50:33 -0000
***************
*** 667,672 ****
--- 667,673 ----
  		}
  		sleep(selwatch_timeout);
  	}
+ 	return 0;
  }
  /*************************************************************************/
  
***************
*** 737,756 ****
  		FILE *fp;
  		struct stat st1;
  
- 		ipmi_start_daemon(eintf->intf);
- 
  		if (lstat(pidfile, &st1) == 0) {
! 			/* already exists, erase first */
! 			if (unlink(pidfile) != 0) {
! 				lprintf(LOG_WARN, "Unable to erase pidfile");
! 			}
  		}
  
  		fp = ipmi_open_file_write(pidfile);
! 		if (fp != NULL) {
! 			fprintf(fp, "%d\n", (int)getpid());
! 			fclose(fp);
  		}
  	}
  
  	/* register signal handler for cleanup */
--- 738,763 ----
  		FILE *fp;
  		struct stat st1;
  
  		if (lstat(pidfile, &st1) == 0) {
! 			/* PID file already exists -> exit. */
! 			lprintf(LOG_ERR, "PID file '%s' already exists. Stalled file?\n",
! 					pidfile);
! 			return -1;
  		}
  
+ 		ipmi_start_daemon(eintf->intf);
+ 		
+ 		umask(022);
  		fp = ipmi_open_file_write(pidfile);
! 		if (fp == NULL) {
! 			/* Failed to get fp on PID file -> exit. */
! 			lprintf(LOG_ERR,
! 					"Failed to open PID file '%s' for writing. Check file permission.\n",
! 					pidfile);
! 			exit(EXIT_FAILURE);
  		}
+ 		fprintf(fp, "%d\n", (int)getpid());
+ 		fclose(fp);
  	}
  
  	/* register signal handler for cleanup */
