Permalink
Browse files

Merge pull request #7 from RhubarbSin/master

Switch from system() to open2()
  • Loading branch information...
2 parents a346864 + f2cfaa4 commit 79dad9368bef7912a4afa8ca9e1b8f4231adac82 @chrismgray committed Aug 16, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 perl/new_org.pm
View
10 perl/new_org.pm 100644 → 100755
@@ -5,6 +5,7 @@ use warnings;
use strict;
use IkiWiki 3.00;
use File::Temp qw/ tempfile unlink0 /;
+use IPC::Open2;
my $org_file_regexp = qr/\.org$/;
@@ -21,18 +22,21 @@ sub run_func_in_emacs($$;$) {
# WARNING: possible security hole
$args =~ s/'/'\\''/g;
my $argstring = qq/unset ALTERNATE_EDITOR; emacsclient -s org-ikiwiki-compiler --eval '(ikiwiki-org-$func "$tn1" "$tn2" $args)'/;
- system($argstring);
+ my $pid = open2(*IN, *OUT, $argstring);
# Wait for emacs to finish
+ waitpid($pid, 0);
my @ret = <$tf2>;
unlink0($tf1, $tn1);
unlink0($tf2, $tn2);
return @ret;
}
sub import {
- system("unset ALTERNATE_EDITOR; emacsclient -s org-ikiwiki-compiler --eval nil");
+ my $pid = open2(*IN, *OUT, "unset ALTERNATE_EDITOR; emacsclient -s org-ikiwiki-compiler --eval nil");
+ waitpid($pid, 0);
if ($? != 0) {
- system("emacs --daemon --eval \"(progn (require 'ikiwiki-org-plugin) (setq server-name \\\"org-ikiwiki-compiler\\\") (server-start))\"");
+ $pid = open2(*IN, *OUT, "emacs --daemon --eval \"(progn (require 'ikiwiki-org-plugin) (setq server-name \\\"org-ikiwiki-compiler\\\") (server-start))\"");
+ waitpid($pid, 0);
if ($? != 0) {
print STDERR "Failed to start emacs. Will not continue with new_org setup.\n";
return;

0 comments on commit 79dad93

Please sign in to comment.