fuxed_lock 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/fuxed_lock.rb +83 -0
  2. metadata +76 -0
data/lib/fuxed_lock.rb ADDED
@@ -0,0 +1,83 @@
1
+ #--
2
+ # Copyleft shura. [ shura1991@gmail.com ]
3
+ #
4
+ # This file is part of fuxed_lock.
5
+ #
6
+ # fuxed_lock is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # fuxed_lock is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with fuxed_lock. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+ require 'ffi'
20
+
21
+ module LibC
22
+ extend FFI::Library
23
+
24
+ ffi_lib ?c
25
+
26
+ class FILE < FFI::Struct
27
+ layout :_flags, :int,
28
+ :_IO_read_ptr, :string,
29
+ :_IO_read_end, :string,
30
+ :_IO_read_base, :string,
31
+ :_IO_write_base, :string,
32
+ :_IO_write_ptr, :string,
33
+ :_IO_write_end, :string,
34
+ :_IO_buf_base, :string,
35
+ :_IO_buf_end, :string,
36
+ :_IO_save_base, :string,
37
+ :_IO_backup_base, :string,
38
+ :_IO_save_end, :string,
39
+ :_IO_marker, :pointer,
40
+ :_chain, :pointer,
41
+ :_fileno, :int,
42
+ :_flags2, :int,
43
+ :_old_offset, :long,
44
+ :_cur_column, :ushort,
45
+ :_vtable_offset, :char,
46
+ :_shortbuf, [:char, 1],
47
+ :_lock, :pointer
48
+ end
49
+
50
+ attach_function :popen, [:string, :string], :pointer
51
+ attach_function :pclose, [:pointer], :int # useless
52
+ attach_function :system, [:string], :int
53
+ end
54
+
55
+ module Kernel
56
+ def self.popen(cmd, mode = ?r)
57
+ return unless [?r, ?w].include? mode
58
+ fp = LibC.popen(cmd, mode)
59
+ return if fp.null?
60
+ fp = LibC::FILE.new(fp)
61
+ IO.new(fp[:_fileno], mode)
62
+ end
63
+
64
+ def self.`(cmd)
65
+ pipe = self.popen(cmd)
66
+ res = pipe.read
67
+ pipe.close
68
+ return res
69
+ end
70
+
71
+ def self.system(cmd)
72
+ LibC.system(cmd)
73
+ end
74
+ end
75
+
76
+ def `(cmd)
77
+ Kernel.send(:`, cmd)
78
+ end
79
+
80
+ def system(cmd)
81
+ Kernel.system(cmd)
82
+ end
83
+
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuxed_lock
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - shura
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-19 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: ffi
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Workaround to avoid FUTEX_LOCK bug (i need it for sublets in subtle wm)
34
+ email: shura1991@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - lib/fuxed_lock.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/shurizzle/fuxed_lock
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Workaround to avoid FUTEX_LOCK bug (i need it for sublets in subtle wm)
75
+ test_files: []
76
+