OSDN Git Service

Switch oneit to use xopen_stdio() for -c (oops) and switch XVFORK() to use
authorRob Landley <rob@landley.net>
Sat, 4 Feb 2017 06:34:31 +0000 (00:34 -0600)
committerRob Landley <rob@landley.net>
Sat, 4 Feb 2017 06:34:31 +0000 (00:34 -0600)
__attribute__((returns_twice)) instead of noinline.

Yes LLVM supports it: https://llvm.org/bugs/show_bug.cgi?id=6287

lib/lib.h
lib/xwrap.c
toys/other/oneit.c

index 2cb0c07..e90e79f 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -322,7 +322,7 @@ void mode_to_string(mode_t mode, char *buf);
 char *getbasename(char *name);
 void names_to_pid(char **names, int (*callback)(pid_t pid, char *name));
 
-pid_t xvforkwrap(pid_t pid);
+pid_t __attribute__((returns_twice)) xvforkwrap(pid_t pid);
 #define XVFORK() xvforkwrap(vfork())
 
 // Wrapper to make xfuncs() return (via longjmp) instead of exiting.
index 611bdb5..2e52d6b 100644 (file)
@@ -163,7 +163,7 @@ void xflush(void)
 // share a stack, so child returning from a function would stomp the return
 // address parent would need. Solution: make vfork() an argument so processes
 // diverge before function gets called.
-pid_t __attribute__((noinline)) xvforkwrap(pid_t pid)
+pid_t __attribute__((returns_twice)) xvforkwrap(pid_t pid)
 {
   if (pid == -1) perror_exit("vfork");
 
index 9be67c0..68b5bd8 100644 (file)
@@ -79,7 +79,7 @@ void oneit_main(void)
   while (!toys.signal) {
 
     // Create a new child process.
-    pid = vfork();
+    pid = XVFORK();
     if (pid) {
 
       // pid 1 reaps zombies until it gets its child, then halts system.
@@ -96,7 +96,7 @@ void oneit_main(void)
       for (i=0; i<3; i++) {
         close(i);
         // Remember, O_CLOEXEC is backwards for xopen()
-        xopen(TT.console ? TT.console : "/dev/tty0", O_RDWR|O_CLOEXEC);
+        xopen_stdio(TT.console ? TT.console : "/dev/tty0", O_RDWR|O_CLOEXEC);
       }
 
       // Can't xexec() here, we vforked so we don't want to error_exit().