[#4754] Now,I am starting ruby. — mamoru@... (Mamoru Matushita)

先日、初めて投稿したつもりだったのですが間違えて

14 messages 1997/10/02

[#4891] mixin - singleton method inheritance, const etc... — shugo@... (Shugo Maeda)

前田です。

13 messages 1997/10/10

[#5000] ruby 1.0-971015 released — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

14 messages 1997/10/15

[#5056] RubyでOODB — hisanori@...

松尾です。

20 messages 1997/10/20
[#5057] Re: RubyでOODB — matz@... (Yukihiro Matsumoto) 1997/10/20

まつもと ゆきひろです

[#5065] Re: RubyでOODB — hisanori@... 1997/10/20

松尾です。

[#5066] Re: RubyでOODB — matz@... (Yukihiro Matsumoto) 1997/10/20

まつもと ゆきひろです

[ruby-list:4813] Re: Now,I am starting ruby.

From: mamoru@... (Mamoru Matushita)
Date: 1997-10-06 11:57:27 UTC
List: ruby-list #4813
WATANABE Hirofum wrote:

> わたなべです.
>
> Mamoru Matushita <mamoru@po.kannet.or.jp> writes:
>
> :ところでflock関数(?)を試してみたところ
> :「The flock() function is unimplemented on this machine.」
> :と怒られてしまいました。これはPerlの時と同じく、Windows
> :環境では使えないって事なのでしょうか?
>
> 使えません. 他にも unimplemented と表示されるものは使えません.
>
> symlink なんですが, cygwin32 版は単なるエミュレーションなの
> で, 排他制御に使うことはできません.
> atomic に test & set できるとしたら mkdir ぐらいかな.

symlinkでも動いているように見えたんですが気のせいだったようですね。
とりあえずmkdirを使ってロックファイルを実現してみました。
どうもありがとうございました。
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
$data="./test.dat";
$lock="./lock";

#new
begin
 check_file=open($data,"r")
rescue
 new_file=open($data,"w")
 new_file.print "0\n"
 new_file.close
end

#lock
try=0
begin
 Dir.mkdir($lock)
rescue
 try+=1
 if try>5 then
  print"error\n"
  Dir.rmdir($lock)
  exit 0
 else
  sleep(2)
  retry
 end
end

count=open($data,"r")
c=count.gets.to_i
c+=1
count.close

count=open($data,"w")
count.print c
count.close

count=open($data,"r")
c=count.gets
count.close

#html
print"Content-type:text/html\n\n";
print"<html><head><title>count test</title></head>\n";
print"<body>\n";
print c;
print"</body></html>\n";

Dir.rmdir($lock)
exit 0
-----------------------------------------------------------
ホームページ随時更新中!! 遊びに来てね。
I like it!(http://www.kannet.or.jp/matusita/index.htm)
Java Java Java(http://www.kannet.or.jp/matusita/jindex.htm)
 

In This Thread

Prev Next