Topic: userhook1 problem
When I run this command from the console prompt it works just fine, but when I run it from userhook1
it causes a segmentation fault. I am trying to get two programs to talk to each other one in background and one
in forground.
Command works from console:
/mnt/storage/part1 & /mnt/storage/part2
Here is userhook1:
/mnt/storage/part1 & /mnt/storage/part2
Here is part1.c:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t CurTime;
time_t OldTime;
FILE * talk;
for(;;)
{
CurTime = time(&CurTime);
if ((CurTime != OldTime) && (0 == (CurTime % 5)))
{
talk = fopen("/tmp/talk","wc");
fprintf(talk,"The current time is %ld\n",CurTime);
OldTime = CurTime;
fclose(talk);
}
}
return 0;
}
Here is part2.c:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t CurTime;
time_t OldTime;
FILE * listen;
char line [100]={'\0'};
for(;;)
{
CurTime = time(&CurTime);
if ((CurTime != OldTime) && (3 == (CurTime % 5)))
{
listen = fopen("/tmp/talk","rc");
fgets(line,sizeof(line),listen);
fclose(listen);
printf("Line was %s",line);
OldTime = CurTime;
}
}
return 0;
}
Since it always works from the command line and always crashes from userhook1 how do I track down this issue?
HELP!