TT#28113 Rename instead of overwriting the target config file

Files that are being executed cannot be modified in place as that
returns EBUSY. But their dentry can be replaced with a rename(2),
which is atomic and does not touch the original inode. This is the
standard procedure to replace running executables in Unix.

So, we just replace the cat(1) with a mv(1), and stop quiescing its
stderr so that we get proper errors reported.

Change-Id: If15ea1cfa749a6140ff4022200c7fc730c76aa3a
changes/79/22479/2
Guillem Jover 8 years ago
parent 32a6a6b62d
commit 7480ebe7c5

@ -82,10 +82,9 @@ tt_tmp_output_file="$(mktemp ngcpcfg."${tt_tmp_output_file_base}".XXXXXXXXXX)"
log_debug "Output file ${output_file} based on ${input_file}"
log_debug "Executing: $TT_WRAPPER ${input_file} > ${tt_tmp_output_file}"
log_debug " and: cat ${tt_tmp_output_file} > ${output_file}"
log_debug " and: mv ${tt_tmp_output_file} ${output_file}"
if "$TT_WRAPPER" "${input_file}" > "${tt_tmp_output_file}" 2>/dev/null &&
cat "${tt_tmp_output_file}" > "${output_file}" 2>/dev/null ; then
rm -f "${tt_tmp_output_file}"
mv "${tt_tmp_output_file}" "${output_file}" ; then
log_info "Generating ${output_file}: OK"
RC=0
else

Loading…
Cancel
Save