2 * Permission to use, copy, modify, and/or distribute this software for
3 * any purpose with or without fee is hereby granted.
5 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
7 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
8 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
10 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
11 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 #include <sys/types.h>
31 sprintf(buf
, "/tmp/zts-zed_fd_spill-logdir/%d", getppid());
32 int fd
= creat(buf
, 0644);
34 (void) fprintf(stderr
, "creat(%s) failed: %s\n", buf
,
39 if (dup2(fd
, STDOUT_FILENO
) == -1) {
41 (void) fprintf(stderr
, "dup2(%s, STDOUT_FILENO) failed: %s\n",
42 buf
, strerror(errno
));
46 snprintf(buf
, sizeof (buf
), "/proc/%d/fd", getppid());
47 execlp("ls", "ls", buf
, NULL
);