summaryrefslogtreecommitdiff
path: root/lib/chef/provider/cron.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/cron.rb')
-rw-r--r--lib/chef/provider/cron.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 19fe9a64af..4430e3e18f 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -196,10 +196,17 @@ class Chef
end
def write_crontab(crontab)
+ write_exception = false
status = popen4("crontab -u #{@new_resource.user} -", :waitlast => true) do |pid, stdin, stdout, stderr|
- stdin.write crontab
+ begin
+ stdin.write crontab
+ rescue Errno::EPIPE => e
+ # popen4 could yield while child has already died.
+ write_exception = true
+ Chef::Log.debug("#{e.message}")
+ end
end
- if status.exitstatus > 0
+ if status.exitstatus > 0 || write_exception
raise Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: #{status.exitstatus}"
end
end