/usr/bin/sclangpipe_app is in supercollider-vim 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/usr/bin/env ruby
#SCvim pipe
#this is a script to pass things from scvim to sclang
#
#Copyright 2007 Alex Norman
#
#This file is part of SCVIM.
#
#SCVIM is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#SCVIM is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with SCVIM. If not, see <http://www.gnu.org/licenses/>.
require 'fileutils'
require 'open3'
require 'optparse'
pipe_loc = "/tmp/sclang-pipe" unless (pipe_loc = ENV["SCVIM_PIPE_LOC"])
rundir = "/tmp/"
if ENV["SCLANG_RUNDIR"]
rundir = ENV["SCLANG_RUNDIR"]
elsif RUBY_PLATFORM =~ /darwin/
rundir = "/Applications/SuperCollider/"
end
pid_loc = "/tmp/sclangpipe_app-pid" unless (pid_loc = ENV["SCVIM_PIPE_PID_LOC"])
app = nil
[
`which sclang`.chomp,
'/Applications/SuperCollider/SuperCollider.app/Contents/Resources/sclang',
'/Applications/SuperCollider/sclang',
].each do |l|
if File.exists?(l)
app = l
break
end
end
unless app
puts "cannot find sclang executable, is it in your path?"
exit -1
end
sclangargs = "-i scvim" # this arg must always be passed, so that sclang knows to load classes from folders named "scide_scvim"
opts = OptionParser.new do |opts|
opts.on("-h", "--help", "Display this help") do
puts opts
exit
end
opts.on("-d <path>", "Set runtime directory") do |d|
rundir = d
end
opts.on("-g <memory-growth>[km]", "Set heap growth (default 256k)") do |g|
sclangargs = sclangargs + " -g #{g}"
end
opts.on("-l <path>", "Set library configuration file") do |l|
sclangargs = sclangargs + " -l #{l}"
end
opts.on("-m <memory-space>[km]", "Set initial heap size (default 2m)") do |m|
sclangargs = sclangargs + " -m #{m}"
end
opts.on("-u <network-port-number>", "Set UDP listening port (default 57120)") do |p|
sclangargs = sclangargs + " -u #{p}"
end
opts.on("-r", "Call Main.run on startup") do
sclangargs = sclangargs + " -r"
end
opts.on("-s", "Call Main.stop on shutdown") do
sclangargs = sclangargs + " -s"
end
end
opts.parse!(ARGV)
File.open(pid_loc, "w"){ |f| f.puts Process.pid }
#remove the pipe if it exists
FileUtils.rm(pipe_loc) if File.exists?(pipe_loc)
#make a new pipe
system("mkfifo", pipe_loc)
pipeproc = Proc.new {
trap("INT") do
Process.exit
end
IO.popen("#{app} -d #{rundir.chomp} #{sclangargs}", "w") do |sclang|
loop {
x = `cat #{pipe_loc}`
sclang.print x if x
}
end
}
$p = Process.fork { pipeproc.call }
#if we get a hup then we kill the pipe process and
#restart it
trap("HUP") do
Process.kill("INT", $p)
$p = Process.fork { pipeproc.call }
end
#clean up after us
trap("INT") do
FileUtils.rm(pipe_loc)
FileUtils.rm(pid_loc)
exit
end
#we sleep until a signal comes
sleep(1) until false
|