Lines Matching defs:pidfile
532 int DhcpFunction::InitPidfile(const std::string& piddir, const std::string& pidfile)
534 if (piddir.empty() || pidfile.empty()) {
535 DHCP_LOGE("InitPidfile() failed, piddir or pidfile is empty!");
538 DHCP_LOGI("InitPidfile() piddir:%{public}s, pidfile:%{public}s.", piddir.c_str(), pidfile.c_str());
539 unlink(pidfile.c_str());
542 if ((fd = open(pidfile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
543 DHCP_LOGE("InitPidfile() failed, open pidfile:%{public}s err:%{public}d!", pidfile.c_str(), errno);
549 DHCP_LOGE("InitPidfile() %{public}s failed, snprintf_s error:%{public}d!", pidfile.c_str(), errno);
555 DHCP_LOGE("InitPidfile() failed, write pidfile:%{public}s error:%{public}d, bytes:%{public}zd!",
556 pidfile.c_str(), errno, bytes);
560 DHCP_LOGI("InitPidfile() pid:%{public}s write %{public}s, bytes:%{public}zd!", buf, pidfile.c_str(), bytes);
572 chmod(pidfile.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
577 pid_t DhcpFunction::GetPID(const std::string& pidfile)
579 /* Check pidfile is or not exists. */
581 if (stat(pidfile.c_str(), &sb) != 0) {
582 DHCP_LOGW("GetPID() pidfile:%{public}s stat:%{public}d!", pidfile.c_str(), errno);
585 DHCP_LOGI("GetPID() pidfile:%{public}s stat st_size:%{public}d.", pidfile.c_str(), (int)sb.st_size);
588 if ((fd = open(pidfile.c_str(), O_RDONLY)) < 0) {
589 DHCP_LOGE("GetPID() failed, open pidfile:%{public}s error!", pidfile.c_str());
598 DHCP_LOGE("GetPID() failed, read pidfile:%{public}s error, bytes:%{public}zd!", pidfile.c_str(), bytes);
602 DHCP_LOGI("GetPID() read pidfile:%{public}s, buf:%{public}s, bytes:%{public}zd.", pidfile.c_str(), buf, bytes);