Article View: comp.unix.programmer
Article #883Re: how to put a program into .plan file
From: Carl Edman
Date: Thu, 27 Sep 1990 01:29
Date: Thu, 27 Sep 1990 01:29
59 lines
2139 bytes
2139 bytes
In article <1990Sep26.155456.1656@agate.berkeley.edu> labb-4ac@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@cory.berkeley.edu.
Thank you so much for your reply.
Name: Andrew Choi
Internet Address: achoi@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@golem.ps.uci.edu
in the laboratory. | edmanc@uciph0.ps.uci.edu
Technical Details
Message-ID:
<CEDMAN.90Sep26182933@lynx.ps.uci.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!cedmanReferences:
<1990Sep26.155456.1656@agate.berkeley.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!cedman From: cedman@lynx.ps.uci.edu (Carl Edman) Newsgroups: comp.unix.programmer Subject: Re: how to put a program into .plan file Message-ID: <CEDMAN.90Sep26182933@lynx.ps.uci.edu> Date: 27 Sep 90 01:29:36 GMT References: <1990Sep26.155456.1656@agate.berkeley.edu> Organization: non serviam Lines: 59 Nntp-Posting-Host: lynx.ps.uci.edu In-reply-to: labb-4ac@web-4b.berkeley.edu's message of 26 Sep 90 15:54:56 GMT