void osl_write_pidfile(undefined4 *param_1)
{
char *__s;
int *piVar1;
char *__pid;
int iVar2;
__pid_t _Var3;
size_t __n;
ssize_t sVar4;
char *pcVar5;
char *pcVar6;
char *unaff_s2;
char *pcVar7;
char *local_80;
char acStack_7c [16];
char acStack_6c [88];
snprintf(acStack_6c,0x50,"/var/run/%s-%.10s.pid",g_Progname,*param_1) //possible issue identified - semgrep
__s = (char *)open(acStack_6c,0) //possible issue identified - semgrep
if ((int)__s < 0) {
piVar1 = __errno_location();
if (*piVar1 == 2) goto LAB_00403f44;
__pid = strerror(*piVar1);
pcVar5 = "osl_write_pidfile: opening pidfile %s for read: %s\n";
}
else {
unaff_s2 = acStack_7c;
sVar4 = read((int)__s,unaff_s2,0x10) //possible issue identified - semgrep
pcVar7 = unaff_s2;
if (-1 < sVar4) goto LAB_00403eb4;
piVar1 = __errno_location();
__pid = strerror(*piVar1);
pcVar5 = "osl_write_pidfile: read of pre-existing %s failed: %s\n";
}
while( true ) {
while( true ) {
pcVar6 = acStack_6c;
pcVar7 = unaff_s2;
while( true ) {
while( true ) {
die(pcVar5,pcVar6,__pid);
unaff_s2 = pcVar5;
LAB_00403eb4:
__pid = (char *)strtol(unaff_s2,&local_80,10);
if ((*local_80 == '\0') || (*local_80 == '\n')) break;
pcVar5 = "osl_write_pidfile: couldn\'t parse \"%s\" as a pid (from file %s); aborting\n";
pcVar6 = pcVar7;
__pid = acStack_6c;
}
iVar2 = kill((__pid_t)__pid,0);
if (iVar2 != 0) break;
pcVar5 = "osl_write_pidfile: %s contains pid %d which is still running; aborting\n";
pcVar6 = acStack_6c;
}
close((int)__s);
LAB_00403f44:
unaff_s2 = acStack_6c;
iVar2 = open(unaff_s2,0x301,0x1a4) //possible issue identified - semgrep
if (-1 < iVar2) break;
piVar1 = __errno_location();
__pid = strerror(*piVar1);
pcVar5 = "osl_write_pidfile: open %s for write/create: %s\n";
}
__s = acStack_7c;
_Var3 = getpid();
snprintf(__s,0x10,"%d\n",_Var3) //possible issue identified - semgrep
__n = strlen(__s);
sVar4 = write(iVar2,__s,__n);
if (-1 < sVar4) break;
piVar1 = __errno_location();
__pid = strerror(*piVar1);
pcVar5 = "osl_write_pidfile: writing my PID to lockfile %s: %s\n";
}
close(iVar2);
return;
}