xpcomcore-rubygem 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
Binary file
|
@@ -1,11 +1,18 @@
|
|
1
1
|
#include <stdlib.h>
|
2
2
|
#include <stdio.h>
|
3
3
|
#include <unistd.h>
|
4
|
+
#include <string.h>
|
4
5
|
|
5
6
|
int main (int argc, const char * argv[]) {
|
6
7
|
char *executable = NULL;
|
8
|
+
char *tee_out_cmd;
|
9
|
+
char *tee_err_cmd;
|
10
|
+
char *hijacked_stdout = NULL;
|
11
|
+
char *hijacked_stderr = NULL;
|
7
12
|
char *exec_args[argc + 1];
|
8
13
|
int i;
|
14
|
+
FILE *hijacked_stdout_fd;
|
15
|
+
FILE *hijacked_stderr_fd;
|
9
16
|
|
10
17
|
executable = getenv("REAL_EXECUTABLE");
|
11
18
|
exec_args[0] = executable;
|
@@ -14,6 +21,23 @@ int main (int argc, const char * argv[]) {
|
|
14
21
|
exec_args[i] = (char *) argv[i];
|
15
22
|
}
|
16
23
|
|
24
|
+
if (getenv("HIJACK_OUTPUT") != NULL) {
|
25
|
+
hijacked_stdout = getenv("HIJACKED_STDOUT");
|
26
|
+
hijacked_stderr = getenv("HIJACKED_STDERR");
|
27
|
+
|
28
|
+
tee_out_cmd = (char *)malloc(strlen("tee ") + strlen(hijacked_stdout) + 1);
|
29
|
+
tee_err_cmd = (char *)malloc(strlen("tee ") + strlen(hijacked_stderr) + 1);
|
30
|
+
|
31
|
+
sprintf(tee_out_cmd, "tee %s", hijacked_stdout);
|
32
|
+
sprintf(tee_err_cmd, "tee %s", hijacked_stderr);
|
33
|
+
|
34
|
+
hijacked_stdout_fd = popen(tee_out_cmd, "w");
|
35
|
+
hijacked_stderr_fd = popen(tee_err_cmd, "w");
|
36
|
+
|
37
|
+
dup2(fileno(hijacked_stdout_fd), STDOUT_FILENO);
|
38
|
+
dup2(fileno(hijacked_stderr_fd), STDERR_FILENO);
|
39
|
+
}
|
40
|
+
|
17
41
|
exec_args[argc] = NULL;
|
18
42
|
return execv(executable, exec_args);
|
19
43
|
}
|
@@ -3,6 +3,7 @@ require 'xpcomcore-rubygem/commands'
|
|
3
3
|
require 'sys/uname'
|
4
4
|
require 'pathname'
|
5
5
|
require 'iniparse'
|
6
|
+
require 'tempfile'
|
6
7
|
|
7
8
|
module XPCOMCore
|
8
9
|
class CommandParser
|
@@ -58,7 +59,21 @@ module XPCOMCore
|
|
58
59
|
def launch_from_stub(xre_location, stub_location)
|
59
60
|
ENV['REAL_EXECUTABLE'] = xre_location.to_s
|
60
61
|
XPCOMCore::CommandParser.log("Launching XUL application using stub '#{stub_location}' and XULRunner '#{xre_location}' from '#{@options[:ini_path].expand_path}'")
|
61
|
-
|
62
|
+
prepare_for_output_hijacking
|
63
|
+
system("open", stub_location.to_s, "--args", *["-app", @options[:ini_path].expand_path.to_s, "-no-remote", *@options[:args]])
|
64
|
+
puts "I helpfully hijacked stdout and stderr back from LaunchServices for you. What follows is coming from your application."
|
65
|
+
exec(%Q[cat "#{ENV['HIJACKED_STDOUT']}" & cat "#{ENV['HIJACKED_STDERR']}" >&2])
|
66
|
+
end
|
67
|
+
|
68
|
+
def prepare_for_output_hijacking
|
69
|
+
ENV['HIJACK_OUTPUT'] = 'true'
|
70
|
+
output_file, error_file = Tempfile.new("stdout.pipe."), Tempfile.new("stdout.pipe.")
|
71
|
+
output_path, error_path = output_file.path, error_file.path
|
72
|
+
output_file.close!
|
73
|
+
error_file.close!
|
74
|
+
system("mkfifo", "-m", "600", output_path) && system("mkfifo", "-m", "600", error_path)
|
75
|
+
ENV['HIJACKED_STDOUT'] = output_path
|
76
|
+
ENV['HIJACKED_STDERR'] = error_path
|
62
77
|
end
|
63
78
|
|
64
79
|
def find_stub
|
@@ -85,6 +100,7 @@ module XPCOMCore
|
|
85
100
|
class LinuxLauncher < BaseLauncher
|
86
101
|
|
87
102
|
def launch
|
103
|
+
super
|
88
104
|
xre_location = send(:"locate_#{@options[:runner_type]}")
|
89
105
|
launch_xre(xre_location)
|
90
106
|
end
|
data/xpcomcore-rubygem.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xpcomcore-rubygem}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ggironda"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-16}
|
13
13
|
s.default_executable = %q{xpcomcore}
|
14
14
|
s.description = %q{Gem to allow for using XPCOMCore via RubyGems}
|
15
15
|
s.email = %q{gabriel.gironda@gmail.com}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xpcomcore-rubygem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ggironda
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-16 00:00:00 -05:00
|
13
13
|
default_executable: xpcomcore
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|