1 parent
ec330c1bc5
commit
6ca07b1bfc
3 files changed
+26
-9
No files matched your search
@@ -49,8 +49,7 @@ func newApp(ui *ui, nav *nav) *app {
|
|||||||
case os.Interrupt:
|
case os.Interrupt:
|
||||||
return
|
return
|
||||||
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
||||||
app.writeHistory()
|
app.quit()
|
||||||
os.Remove(gLogPath)
|
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -59,6 +58,16 @@ func newApp(ui *ui, nav *nav) *app {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *app) quit() {
|
||||||
|
if err := remote(fmt.Sprintf("drop %d", gClientID)); err != nil {
|
||||||
|
log.Printf("dropping connection: %s", err)
|
||||||
|
}
|
||||||
|
if err := app.writeHistory(); err != nil {
|
||||||
|
log.Printf("writing history file: %s", err)
|
||||||
|
}
|
||||||
|
os.Remove(gLogPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (app *app) readFile(path string) {
|
func (app *app) readFile(path string) {
|
||||||
log.Printf("reading file: %s", path)
|
log.Printf("reading file: %s", path)
|
||||||
|
|
||||||
@@ -280,14 +289,12 @@ func (app *app) loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.quit()
|
||||||
|
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
|
|
||||||
log.Print("bye!")
|
log.Print("bye!")
|
||||||
|
|
||||||
if err := app.writeHistory(); err != nil {
|
|
||||||
log.Printf("writing history file: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if gLastDirPath != "" {
|
if gLastDirPath != "" {
|
||||||
f, err := os.Create(gLastDirPath)
|
f, err := os.Create(gLastDirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -463,8 +470,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := app.ui.resume(); err != nil {
|
if err := app.ui.resume(); err != nil {
|
||||||
app.writeHistory()
|
app.quit()
|
||||||
os.Remove(gLogPath)
|
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func run() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer os.Remove(gLogPath)
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,18 @@ Loop:
|
|||||||
} else {
|
} else {
|
||||||
log.Print("listen: conn: requires a client id")
|
log.Print("listen: conn: requires a client id")
|
||||||
}
|
}
|
||||||
|
case "drop":
|
||||||
|
if rest != "" {
|
||||||
|
word2, _ := splitWord(rest)
|
||||||
|
id, err := strconv.Atoi(word2)
|
||||||
|
if err != nil {
|
||||||
|
log.Print("listen: drop: client id should be a number")
|
||||||
|
} else {
|
||||||
|
delete(gConnList, id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Print("listen: drop: requires a client id")
|
||||||
|
}
|
||||||
case "send":
|
case "send":
|
||||||
if rest != "" {
|
if rest != "" {
|
||||||
word2, rest2 := splitWord(rest)
|
word2, rest2 := splitWord(rest)
|
||||||
|
|||||||
Reference in new issue
Block a user