close $gpgv_output; close $gpgv_log;
close $gpgv_status; close $gpgv_flag;
+ our $AbortPipe = $gpgv_flag_sink; # pipe to parent
+ our $AbortExitCode = 120; # arbitrary 7-bit exit code
+ # no need to use local here; this process will either exec or abort
+
# Adjust close-on-exec flags:
my $flags;
# - clear on status and log sinks
- unless ($flags = fcntl $gpgv_status_sink, F_GETFD, 0) {
- print $gpgv_flag_sink "ERR: fcntl F_GETFD on status: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
- unless (fcntl $gpgv_status_sink, F_SETFD, $flags & ~FD_CLOEXEC) {
- print $gpgv_flag_sink "ERR: fcntl F_SETFD on status: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
- unless ($flags = fcntl $gpgv_log_sink, F_GETFD, 0) {
- print $gpgv_flag_sink "ERR: fcntl F_GETFD on log: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
- unless (fcntl $gpgv_log_sink, F_SETFD, $flags & ~FD_CLOEXEC) {
- print $gpgv_flag_sink "ERR: fcntl F_SETFD on log: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
+ $flags = fcntl $gpgv_status_sink, F_GETFD, 0
+ or ftp_abort("ERR: fcntl F_GETFD on status: $!");
+ fcntl $gpgv_status_sink, F_SETFD, $flags & ~FD_CLOEXEC
+ or ftp_abort("ERR: fcntl F_SETFD on status: $!");
+ $flags = fcntl $gpgv_log_sink, F_GETFD, 0
+ or ftp_abort("ERR: fcntl F_GETFD on log: $!");
+ fcntl $gpgv_log_sink, F_SETFD, $flags & ~FD_CLOEXEC
+ or ftp_abort("ERR: fcntl F_SETFD on log: $!");
# - set on flag pipe sink
- unless ($flags = fcntl $gpgv_flag_sink, F_GETFD, 0) {
- print $gpgv_flag_sink "ERR: fcntl F_GETFD on flag: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
- unless (fcntl $gpgv_flag_sink, F_SETFD, $flags | FD_CLOEXEC) {
- print $gpgv_flag_sink "ERR: fcntl F_SETFD on flag: $!\n";
- exit 120; # arbitrary 7.bit exit code
- }
+ $flags = fcntl $gpgv_flag_sink, F_GETFD, 0
+ or ftp_abort("ERR: fcntl F_GETFD on flag: $!");
+ fcntl $gpgv_flag_sink, F_SETFD, $flags | FD_CLOEXEC
+ or ftp_abort("ERR: fcntl F_SETFD on flag: $!");
# Prepare STDIN/STDOUT/STDERR
- unless (open STDIN, '<&', $gpgv_stdin) {
- print $gpgv_flag_sink "ERR: set stdin: $!\n";
- exit 120; # arbitrary 7-bit exit code
- }
- unless (open STDOUT, '>&', $gpgv_output_sink) {
- print $gpgv_flag_sink "ERR: set stdout: $!\n";
- exit 120; # arbitrary 7-bit exit code
- }
- unless (open STDERR, '>&', $gpgv_output_sink) {
- print $gpgv_flag_sink "ERR: set stderr: $!\n";
- exit 120; # arbitrary 7-bit exit code
- }
+ open STDIN, '<&', $gpgv_stdin or ftp_abort("ERR: set stdin: $!");
+ open STDOUT, '>&', $gpgv_output_sink or ftp_abort("ERR: set stdout: $!");
+ open STDERR, '>&', $gpgv_output_sink or ftp_abort("ERR: set stderr: $!");
# Exec gpgv
- exec { GPGV_BIN } @gpgv_args
- or print $gpgv_flag_sink "ERR: $!\n";
- exit 120; # arbitrary 7-bit exit code
+ exec { GPGV_BIN } @gpgv_args or ftp_abort("ERR: $!");
}
# The parent continues here...