how to put a program into .plan file
Carl Edman
cedman at lynx.ps.uci.edu
Thu Sep 27 11:29:36 AEST 1990
In article <1990Sep26.155456.1656 at agate.berkeley.edu> labb-4ac at web-4b.berkeley.edu (superMan (the web dweller)) writes:
Pardon my ignorance, but how can you write a C program which checks the
status of the file to see whether someone has opened it? Exactly what
system call or library function do you use?
Please send reply to Internet address achoi at cory.berkeley.edu.
Thank you so much for your reply.
Name: Andrew Choi
Internet Address: achoi at cory.berkeley.edu
#include <std/disclaimer.h>
Here is the most simple possible solution. Something I tried a few
days ago. Run the output and try "cat tfifo". You will get 3 different
results then the run-ed program will terminate.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
main()
{
int fd;
unlink("tfifo");
mkfifo("tfifo",S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
fd=open("tfifo",O_WRONLY);
write(fd,"test1\n",7);
close(fd);
sleep(1);
fd=open("tfifo",O_WRONLY);
write(fd,"test2\n",7);
close(fd);
sleep(1);
fd=open("tfifo",O_WRONLY);
write(fd,"test3\n",7);
close(fd);
sleep(1);
unlink("tfifo");
}
I hope looking at this code will answer your question (Maybe your system
hasn't got mkfifo, use mknod then).
Theorectial Physicist,N.:A physicist whose | Send mail
existence is postulated, to make the numbers | to
balance but who is never actually observed | cedman at golem.ps.uci.edu
in the laboratory. | edmanc at uciph0.ps.uci.edu
More information about the Comp.unix.programmer
mailing list