Commit 6763d28a authored by zelig's avatar zelig

repl.Stop() to only if running, fixes panic after js> exit followed by interrupt

parent bf57e960
...@@ -23,6 +23,8 @@ type JSRepl struct { ...@@ -23,6 +23,8 @@ type JSRepl struct {
prompt string prompt string
history *os.File history *os.File
running bool
} }
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl { func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
...@@ -35,26 +37,32 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl { ...@@ -35,26 +37,32 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
} }
func (self *JSRepl) Start() { func (self *JSRepl) Start() {
logger.Infoln("init JS Console") if !self.running {
reader := bufio.NewReader(self.history) self.running = true
for { logger.Infoln("init JS Console")
line, err := reader.ReadString('\n') reader := bufio.NewReader(self.history)
if err != nil && err == io.EOF { for {
break line, err := reader.ReadString('\n')
} else if err != nil { if err != nil && err == io.EOF {
fmt.Println("error reading history", err) break
break } else if err != nil {
fmt.Println("error reading history", err)
break
}
addHistory(line[:len(line)-1])
} }
self.read()
addHistory(line[:len(line)-1])
} }
self.read()
} }
func (self *JSRepl) Stop() { func (self *JSRepl) Stop() {
self.re.Stop() if self.running {
logger.Infoln("exit JS Console") self.running = false
self.history.Close() self.re.Stop()
logger.Infoln("exit JS Console")
self.history.Close()
}
} }
func (self *JSRepl) parseInput(code string) { func (self *JSRepl) parseInput(code string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment