summaryrefslogtreecommitdiff
path: root/src/outitf.c
diff options
context:
space:
mode:
authorrahul2019-09-26 15:21:18 +0530
committerrahul2019-09-26 15:21:18 +0530
commit7852873cf0bc8b8082ea847a868ab84930163667 (patch)
treed649b84d09ad7b6017c5439bef0c6112ce525b84 /src/outitf.c
parente43b6221138d30d9b2ea37c708c9521d4ba926af (diff)
downloadnghdl-7852873cf0bc8b8082ea847a868ab84930163667.tar.gz
nghdl-7852873cf0bc8b8082ea847a868ab84930163667.tar.bz2
nghdl-7852873cf0bc8b8082ea847a868ab84930163667.zip
multiple instances (static ip)
Diffstat (limited to 'src/outitf.c')
-rw-r--r--src/outitf.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/outitf.c b/src/outitf.c
index ce3e910..df22af2 100644
--- a/src/outitf.c
+++ b/src/outitf.c
@@ -100,30 +100,38 @@ static void nghdl_tb_SIGUSR1(char* pid_file)
int ret;
char line[80];
char* nptr;
+ pid_t pid[256], tmp;
+ int count=0, i;
FILE* fp = fopen(pid_file, "r");
if (fp)
{
- if (fscanf(fp, "%s", line) != EOF)
+ while (fscanf(fp, "%s", line) == 1)
+ {
+ // PID is converted to a decimal value.
+ tmp = (pid_t) strtol(line, &nptr, 10);
+ if ((errno != ERANGE) && (errno!= EINVAL))
+ {
+ pid[count++] = tmp;
+ }
+ }
+
+ fclose(fp);
+ }
+
+ for(i=0; i<count; i++)
{
- fclose(fp);
- pid_t pid = (pid_t) strtol(line, &nptr, 10);
- // PID is converted to a decimal value.
- if ((errno != ERANGE) && (errno!= EINVAL))
- {
- if (pid)
+ if (pid[i])
{
- // Check if a process with this pid really exists.
- ret = kill(pid, 0);
+ // Check if a process with this pid really exists.
+ ret = kill(pid[i], 0);
if (ret == 0)
{
- kill(pid, SIGUSR1);
+ kill(pid[i], SIGUSR1);
}
}
- }
}
- }
}
/* 10.Mar.2017 - RM - Added nghdl_orphan_tb().*/