- Timestamp:
- Sep 1, 2009, 8:43:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_unix.c
r230 r246 4051 4051 } 4052 4052 4053 int sh_unix_check_piddir (char * pidfile) 4054 { 4055 static struct stat buf; 4056 int status = 0; 4057 char * pid_dir; 4058 4059 SL_ENTER(_("sh_unix_check_piddir")); 4060 4061 pid_dir = sh_util_dirname (pidfile); 4062 4063 status = retry_lstat (FIL__, __LINE__, pid_dir, &buf); 4064 4065 if (status < 0 && errno == ENOENT) 4066 { 4067 status = mkdir (pid_dir, 0777); 4068 if (status < 0) 4069 { 4070 sh_error_handle ((-1), FIL__, __LINE__, status, 4071 MSG_E_SUBGEN, 4072 _("Cannot create PID directory"), 4073 _("sh_unix_check_piddir")); 4074 SH_FREE(pid_dir); 4075 SL_RETURN((-1),_("sh_unix_check_piddir")); 4076 } 4077 } 4078 else if (!S_ISDIR(buf.st_mode)) 4079 { 4080 sh_error_handle ((-1), FIL__, __LINE__, status, 4081 MSG_E_SUBGEN, 4082 _("Path of PID directory refers to a non-directory object"), 4083 _("sh_unix_check_piddir")); 4084 SH_FREE(pid_dir); 4085 SL_RETURN((-1),_("sh_unix_check_piddir")); 4086 } 4087 SH_FREE(pid_dir); 4088 SL_RETURN((0),_("sh_unix_check_piddir")); 4089 } 4090 4053 4091 int sh_unix_lock (char * lockfile, char * flag) 4054 4092 { … … 4063 4101 sprintf (myPid, "%ld\n", (long) sh.pid); /* known to fit */ 4064 4102 4103 if (flag == NULL) /* PID file, check for directory */ 4104 { 4105 if (0 != sh_unix_check_piddir (lockfile)) 4106 { 4107 SL_RETURN((-1),_("sh_unix_lock")); 4108 } 4109 } 4110 4065 4111 fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV); /* fails if file exists */ 4066 4112 … … 4119 4165 sh_error_handle ((-1), FIL__, __LINE__, status, 4120 4166 MSG_E_SUBGEN, 4121 (filename == NULL) ? _("Cannot create PID file ") : _("Cannot create lock file"),4167 (filename == NULL) ? _("Cannot create PID file (1)") : _("Cannot create lock file (1)"), 4122 4168 _("sh_unix_test_and_lock")); 4123 4169 SL_RETURN((-1),_("sh_unix_test_and_lock")); … … 4141 4187 sh_error_handle ((-1), FIL__, __LINE__, status, 4142 4188 MSG_E_SUBGEN, 4143 (filename == NULL) ? _("Cannot create PID file ") : _("Cannot create lock file"),4189 (filename == NULL) ? _("Cannot create PID file (2)") : _("Cannot create lock file (2)"), 4144 4190 _("sh_unix_test_and_lock")); 4145 4191 SL_RETURN((-1),_("sh_unix_test_and_lock")); … … 4230 4276 sh_error_handle ((-1), FIL__, __LINE__, status, 4231 4277 MSG_E_SUBGEN, 4232 (filename == NULL) ? _("Cannot create PID file ") : _("Cannot create lock file"),4278 (filename == NULL) ? _("Cannot create PID file (3)") : _("Cannot create lock file (3)"), 4233 4279 _("sh_unix_test_and_lock")); 4234 4280 }
Note:
See TracChangeset
for help on using the changeset viewer.