File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ main(int argc, char *argv[])
146
146
char tmpdir [MAXPGPATH ] = TMPFS_DIRECTORY "/pg_tde_archiveXXXXXX" ;
147
147
char tmppath [MAXPGPATH ];
148
148
bool issegment ;
149
+ int rc ;
149
150
150
151
pg_logging_init (argv [0 ]);
151
152
progname = get_progname (argv [0 ]);
@@ -208,9 +209,22 @@ main(int argc, char *argv[])
208
209
command = replace_percent_placeholders (command ,
209
210
"ARCHIVE-COMMAND" , "fp" ,
210
211
targetname , sourcepath );
212
+ rc = system (command );
211
213
212
- if (system (command ) != 0 )
213
- pg_fatal ("ARCHIVE-COMMAND \"%s\" failed: %m" , command );
214
+ if (rc != 0 )
215
+ {
216
+ if (rc == -1 )
217
+ pg_fatal ("ARCHIVE-COMMAND \"%s\" failed: %m" , command );
218
+ else if (WIFEXITED (rc ))
219
+ pg_fatal ("ARCHIVE-COMMAND \"%s\" failed with exit code %d" ,
220
+ command , WEXITSTATUS (rc ));
221
+ else if (WIFSIGNALED (rc ))
222
+ pg_fatal ("ARCHIVE-COMMAND \"%s\" was terminated by signal %d: %s" ,
223
+ command , WTERMSIG (rc ), pg_strsignal (WTERMSIG (rc )));
224
+ else
225
+ pg_fatal ("ARCHIVE-COMMAND \"%s\" exited with unrecognized status %d" ,
226
+ command , rc );
227
+ }
214
228
215
229
free (command );
216
230
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ main(int argc, char *argv[])
141
141
char tmpdir [MAXPGPATH ] = TMPFS_DIRECTORY "/pg_tde_restoreXXXXXX" ;
142
142
char tmppath [MAXPGPATH ];
143
143
bool issegment ;
144
+ int rc ;
144
145
145
146
pg_logging_init (argv [0 ]);
146
147
progname = get_progname (argv [0 ]);
@@ -201,9 +202,22 @@ main(int argc, char *argv[])
201
202
command = replace_percent_placeholders (command ,
202
203
"RESTORE-COMMAND" , "fp" ,
203
204
sourcename , targetpath );
205
+ rc = system (command );
204
206
205
- if (system (command ) != 0 )
206
- pg_fatal ("RESTORE-COMMAND \"%s\" failed: %m" , command );
207
+ if (rc != 0 )
208
+ {
209
+ if (rc == -1 )
210
+ pg_fatal ("RESTORE-COMMAND \"%s\" failed: %m" , command );
211
+ else if (WIFEXITED (rc ))
212
+ pg_fatal ("RESTORE-COMMAND \"%s\" failed with exit code %d" ,
213
+ command , WEXITSTATUS (rc ));
214
+ else if (WIFSIGNALED (rc ))
215
+ pg_fatal ("RESTORE-COMMAND \"%s\" was terminated by signal %d: %s" ,
216
+ command , WTERMSIG (rc ), pg_strsignal (WTERMSIG (rc )));
217
+ else
218
+ pg_fatal ("RESTORE-COMMAND \"%s\" exited with unrecognized status %d" ,
219
+ command , rc );
220
+ }
207
221
208
222
free (command );
209
223
You can’t perform that action at this time.
0 commit comments