On Tue, Jan 31, 2017 at 12:00 PM, Mark Galeck <mark_gal...@pacbell.net> wrote:
> This is strange. Why save, dup and dup again to restore, descriptors in the 
> parent, when it would be much simpler to just dup in the child, and not have 
> to save and restore. This is simpler and I checked it works the same:

> I am sure there must be a good reason and I am not understanding something 
> deeper. What is it?

I am not a dash developer, but one reason to make system calls in the
parent is that it is much simpler to handle errors in the parent.

In your example:

> if (!fork()) {
>     fd = open64("foobar.txt", O_WRONLY|O_CREAT);
>     dup2(fd, 1);
>     execl("/bin/date", "date", (char *)NULL);
> }

What happens if open64 fails?  How should the child inform the parent
of this specific error?

-Parke
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to