Module | Backup::CLI::Helpers |
In: |
lib/backup/cli/helpers.rb
|
UTILITY | = | {} |
Inspects the exit code returned from the POpen4 child process. If the exit code isn‘t listed in the process_data[:ignore_exit_codes] array, an exception will be raised, aborting the backup process.
Information regarding the error ( EXIT CODE and STDERR ) will be returned to the shell so the user can investigate the issue.
raises Backup::Errors::CLI::SystemCallError
Runs a given command in an isolated (sub) process using POpen4. The STDOUT, STDERR and the returned exit code of the utility will be stored in the process_data Hash.
If a command returns an exit code other than 0, an exception will raise and the backup process will abort. Some utilities return exit codes other than 0 which aren‘t an issue in Backup‘s context. If this is the case, you can pass in an array of exit codes to ignore (whitelist), for example:
run("tar -cf /output.tar /some/folder", :ignore_exit_codes => [1])
So if the `tar` utility returns in this case 1, Backup will consider it an acceptable return code.
Note: Exit code 0 is always automatically added to the :ignore_exit_codes array, regardless of whether you specify an
array to ignore or not.