@cryptotaxi247 / kubo / commits / 72280f31d

fix ctrl-c prompt during run migrations prompt (#10947)

* fix ctrl-c prompt during run migrations prompt At "Run migrations" prompt, hitting ctrl-c does not show the "(Hit ctrl-c again to force-shutdown the daemon.)" prompt, even though a 2nd ctrl-c does cause the daemon to exit. The problem is that the goroutine that displays the prompt only run after the prompt to "Run migrations", so hitting ctrl-c during the "Run migrations" prompt does not show the "(Hit ctrl-c again to force-shutdown the daemon.)" prompt. This PR fixes the problem by starting the goroutine to display the "(Hit ctrl-c again to force-shutdown the daemon.)" prompt sooner, before the "Run mirgarions" prompt. Additionally, this PR also disables showing the ctrl-c prompt if the daemon function has already exited, in which case only the exit message should be shown. Closes #3157 * exit immediately if ctrl-c during migration prompt

Andrew Gillis committed Sep 4, 2025 at 16:30 UTC 72280f31d4fd06038cfac312c8ce1c12e44884a7
2 files changed +11 -7
cmd/ipfs/kubo/daemon.go
+10
@@ -284,6 +284,15 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
284 default:
285 return err
286 case fsrepo.ErrNeedMigration:
287 + migrationDone := make(chan struct{})
288 + go func() {
289 + select {
290 + case <-req.Context.Done():
291 + os.Exit(1)
292 + case <-migrationDone:
293 + }
294 + }()
295 +
296 domigrate, found := req.Options[migrateKwd].(bool)
297
298 // Get current repo version for more informative message
@@ -299,6 +308,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
308 if !found {
309 domigrate = YesNoPrompt("Run migrations now? [y/N]")
310 }
311 + close(migrationDone)
312
313 if !domigrate {
314 fmt.Printf("Not running migrations on repository at %s. Re-run daemon with --migrate or see 'ipfs repo migrate --help'\n", cctx.ConfigRoot)
cmd/ipfs/util/signal.go
+1 -7
@@ -64,13 +64,7 @@ func SetupInterruptHandler(ctx context.Context) (io.Closer, context.Context) {
64 switch count {
65 case 1:
66 fmt.Println() // Prevent un-terminated ^C character in terminal
67 -
68 - ih.wg.Add(1)
69 - go func() {
70 - defer ih.wg.Done()
71 - cancelFunc()
72 - }()
73 -
67 + cancelFunc()
68 default:
69 fmt.Println("Received another interrupt before graceful shutdown, terminating...")
70 os.Exit(-1)