Skip to content

Instantly share code, notes, and snippets.

@nocd5
Last active September 18, 2015 04:59
Show Gist options
  • Save nocd5/f6f4fce05769fb299f53 to your computer and use it in GitHub Desktop.
Save nocd5/f6f4fce05769fb299f53 to your computer and use it in GitHub Desktop.
nyagos.promptで少し込み入った事をしていると、pipeで落ちる件の対策
diff --git a/main/lua.go b/main/lua.go
index 73e0d16..85d9172 100644
--- a/main/lua.go
+++ b/main/lua.go
@@ -47,6 +47,8 @@ const ERRMSG_CAN_NOT_USE_TWO_LUA_ON = "Can not use two Lua-command on the same p
const ERRMSG_CAN_NOT_RUN_LUA_ON_BACKGROUND = "Can not run Lua-Command on background"
func (this LuaFunction) Call(cmd *interpreter.Interpreter) (interpreter.ErrorLevel, error) {
+ newArgsHookLock.Lock()
+ defer newArgsHookLock.Unlock()
if cmd.IsBackGround {
fmt.Fprintf(os.Stderr, "%s: %s\n",
cmd.Args[0],
@@ -209,6 +211,8 @@ func newArgHook(it *interpreter.Interpreter, args []string) ([]string, error) {
var orgOnCommandNotFound func(*interpreter.Interpreter, error) error
func on_command_not_found(inte *interpreter.Interpreter, err error) error {
+ newArgsHookLock.Lock()
+ defer newArgsHookLock.Unlock()
L, Lok := inte.Tag.(lua.Lua)
if !Lok {
return errors.New("on_command_not_found: Interpreter.Tag is not lua instance")
diff --git a/main/nyagos.go b/main/nyagos.go
index 58393b4..e24f636 100644
--- a/main/nyagos.go
+++ b/main/nyagos.go
@@ -46,6 +46,8 @@ func nyagosPrompt(L lua.Lua) int {
}
func printPrompt(this *conio.LineEditor) (int, error) {
+ newArgsHookLock.Lock()
+ defer newArgsHookLock.Unlock()
it, it_ok := this.Tag.(*interpreter.Interpreter)
if !it_ok {
return 0, errors.New("nyagos.go: printPrompt: conio.LineEditor.Tag is not interpreter.Interpreter")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment