Merge branch from toybox/master
authorHyejin Kim <hyejin0906.kim@samsung.com>
Thu, 16 Jul 2015 05:10:30 +0000 (14:10 +0900)
committerHyejin Kim <hyejin0906.kim@samsung.com>
Thu, 16 Jul 2015 05:10:36 +0000 (14:10 +0900)
Conflicts:
both modified:      lib/portability.c
both modified:      lib/portability.h
both modified:      scripts/genconfig.sh
both modified:      scripts/runtest.sh
both added:         tests/sed.test
both modified:      toys/other/acpi.c
both modified:      toys/other/ifconfig.c
deleted by them:    toys/other/unshare.c
both added:         toys/pending/hwclock.c
both modified:      toys/pending/ip.c
deleted by them:    toys/pending/sed.c
both modified:      toys/posix/chgrp.c
both modified:      toys/posix/cp.c
both modified:      toys/posix/id.c
both modified:      toys/posix/ls.c

Change-Id: Ib36c5267ec054a5683ca37da2383d83b3cb1b5b4
Signed-off-by: Hyejin Kim <hyejin0906.kim@samsung.com>
1  2 
lib/portability.c
tests/sed.test
toys.h
toys/other/netcat.c

@@@ -5,11 -5,32 +5,35 @@@
   */
  
  #include "toys.h"
 +#if defined(__ANDROID__)
 +#include <asm/unistd.h>
 +#endif
  
- #if defined(__APPLE__) || defined(__ANDROID__)
+ // We can't fork() on nommu systems, and vfork() requires an exec() or exit()
+ // before resuming the parent (because they share a heap until then). And no,
+ // we can't implement our own clone() call that does the equivalent of fork()
+ // because nommu heaps use physical addresses so if we copy the heap all our
+ // pointers are wrong. (You need an mmu in order to map two heaps to the same
+ // address range without interfering with each other.) In the absence of
+ // a portable way to tell malloc() to start a new heap without freeing the old
+ // one, you pretty much need the exec().)
+ // So we exec ourselves (via /proc/self/exe, if anybody knows a way to
+ // re-exec self without depending on the filesystem, I'm all ears),
+ // and use the arguments to signal reentry.
+ #if CFG_TOYBOX_FORK
+ pid_t xfork(void)
+ {
+   pid_t pid = fork();
+   if (pid < 0) perror_exit("fork");
+   return pid;
+ }
+ #endif
+ #if defined(__APPLE__)
  ssize_t getdelim(char **linep, size_t *np, int delim, FILE *stream)
  {
    int ch;
diff --cc tests/sed.test
index 2d019eb,9f2956f..9f2956f
mode 100644,100755..100644
diff --cc toys.h
Simple merge
Simple merge