The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Permission to use, copy, modify, and/or distribute this software for
    3  * any purpose with or without fee is hereby granted.
    4  *
    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.
   12  */
   13 
   14 #include <sys/types.h>
   15 #include <sys/wait.h>
   16 #include <errno.h>
   17 #include <fcntl.h>
   18 #include <unistd.h>
   19 #include <stdlib.h>
   20 #include <string.h>
   21 #include <stdio.h>
   22 
   23 int main(void) {
   24         if (fork()) {
   25                 int err;
   26                 wait(&err);
   27                 return (err);
   28         }
   29 
   30         char buf[64];
   31         sprintf(buf, "/tmp/zts-zed_fd_spill-logdir/%d", getppid());
   32         int fd = creat(buf, 0644);
   33         if (fd == -1) {
   34                 (void) fprintf(stderr, "creat(%s) failed: %s\n", buf,
   35                     strerror(errno));
   36                 exit(EXIT_FAILURE);
   37         }
   38 
   39         if (dup2(fd, STDOUT_FILENO) == -1) {
   40                 close(fd);
   41                 (void) fprintf(stderr, "dup2(%s, STDOUT_FILENO) failed: %s\n",
   42                     buf, strerror(errno));
   43                 exit(EXIT_FAILURE);
   44         }
   45 
   46         snprintf(buf, sizeof (buf), "/proc/%d/fd", getppid());
   47         execlp("ls", "ls", buf, NULL);
   48         _exit(127);
   49 }

Cache object: 786c4e98b0211ad037b76e2d5223b2e4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.