Non-zero exit status from rclone mount, even with clean unmount

What is the problem you are having with rclone?

Non-zero exit status from rclone mount

To recreate:

  • rclone mount -vv /tmp/srcdir /tmp/destdir
  • Press Ctrl+C to terminate
  • echo $?

Expected result:

  • Exit status is 0

Actual result:

  • Exit status is 130

The log shows:

<3>ERROR : /tmp/destdir: Unmounted rclone mount

Despite the message and non-zero exit status, the directory is cleanly unmounted (verified via mount command)

cmd/mountlib/mount.go has the following code:

			if err := m.Unmount(); err != nil {
				fs.Errorf(m.MountPoint, "Failed to unmount: %v", err)
			} else {
				fs.Errorf(m.MountPoint, "Unmounted rclone mount")
			}

I'm unfamiliar with Go, but I suspect the else path should not be fs.Errorf, perhaps fs.Debugf instead?

Run the command 'rclone version' and share the full output of the command.

$ rclone --version
rclone 1.60.1
- os/version: fedora 37 (64 bit)
- os/kernel: 6.2.15-200.fc37.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.3
- go/linking: dynamic
- go/tags: none

1.60.1 is the version currently provided by Fedora. I recreated by compiling 1.62.2 as well.

Which cloud storage system are you using? (eg Google Drive)

None. This problem can be recreated by rclone mounting one local directory to another.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount -vv /tmp/srcdir /tmp/destdir

The rclone config contents with secrets removed.

None. This can be recreated with no rclone config in place.

A log from the command with the -vv flag

$ rclone mount -vv /tmp/srcdir /tmp/destdir
<7>DEBUG : rclone: Version "1.60.1" starting with parameters ["rclone" "mount" "-vv" "/tmp/srcdir" "/tmp/destdir"]
<7>DEBUG : rclone: systemd logging support activated
<7>DEBUG : Creating backend with remote "/tmp/srcdir"
<5>NOTICE: Config file "/home/eaking/.config/rclone/rclone.conf" not found - using defaults
<6>INFO  : Local file system at /tmp/srcdir: poll-interval is not supported by this remote
<7>DEBUG : Local file system at /tmp/srcdir: Mounting on "/tmp/destdir"
<7>DEBUG : : Root:
<7>DEBUG : : >Root: node=/, err=<nil>
<7>DEBUG : /: Lookup: name=".Trash"
<7>DEBUG : /: >Lookup: node=<nil>, err=no such file or directory
<7>DEBUG : /: Lookup: name=".Trash-1000"
<7>DEBUG : /: >Lookup: node=<nil>, err=no such file or directory
^C<6>INFO  : Signal received: interrupt
<3>ERROR : /tmp/destdir: Unmounted rclone mount
<6>INFO  : Exiting...
$ echo $?
130

Feel free to submit a PR or file a bug on Github for that.

On further investigation, it looks like the 130 exit status is intentional. From lib/atexit/atexit_unix.go:

// exitCode calculates the exit code for the given signal. Many Unix programs
// exit with 128+signum if they handle signals. Most shell also implement the
// same convention if a program is terminated by an uncaught and/or fatal
// signal.
func exitCode(sig os.Signal) int {
	if real, ok := sig.(syscall.Signal); ok && int(real) > 0 {
		return 128 + int(real)
	}

	return exitcode.UncategorizedError
}

I'm not sure why I thought the categorization of the log message was connected to exit status.

I may (or may not) send a PR to correct the message, at least.

If you exit the program with a signal then you'd expect a non zero status I think.

If you want a zero status, then use fusermount -u /path/to/mountpoint or use the rclone rc and call core/quit.

1 Like

I really didn’t think about that as that’s a great point.

1 Like

Brilliant! Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.