Subject: bug#17470: [PATCH] sort: rotate on ENOSPC while creating tmp files

From: Paul Eggert <[email-masked]>
Date: Sun, 11 May 2014 15:25:56 -0700

Azat Khuzhin wrote:

> +      fd = mkstemp (file);
> +
> +      if (errno != ENOSPC || temp_dir_index == start_dir_index)

This assumes that when mkstemp succeeds then errno != ENOSPC, which is 
not necessarily true.

More generally, it appears that with the patch 'sort' checks whether one 
can create a file, but 'sort' will still respond poorly if a write to a 
temp file fails due to filesystem space exhaustion.