#define FILE_WRITE_ERRORS \
PARA_ERROR(FW_WRITE, "file writer write error"), \
- PARA_ERROR(FW_OPEN, "file writer: can not open output file"), \
PARA_ERROR(FW_NO_FILE, "task started without open file"), \
sizeof(struct private_file_write_data));
struct file_write_args_info *conf = wn->conf;
char *filename;
+ int ret;
if (conf->filename_given)
filename = conf->filename_arg;
else
filename = random_filename();
wn->private_data = pfwd;
- pfwd->fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
+ ret = para_open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (!conf->filename_given)
free(filename);
- if (pfwd->fd >= 0)
+ if (ret < 0)
+ goto out;
+ pfwd->fd = ret;
+ ret = mark_fd_blocking(pfwd->fd);
+ if (ret >= 0)
return 1;
+ close(pfwd->fd);
+out:
free(pfwd);
- return -E_FW_OPEN;
+ return ret;
}
static void file_write_pre_select(struct sched *s, struct task *t)