--- deliantra/server/common/porting.C 2006/09/10 16:00:23 1.5 +++ deliantra/server/common/porting.C 2006/09/14 22:34:00 1.7 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_porting_c = - * "$Id: porting.C,v 1.5 2006/09/10 16:00:23 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ /* This file contains various functions that are not really unique for @@ -180,46 +174,41 @@ FILE *ret; if (!strcmp (type, "r")) - { - pd = STDOUT_FILENO; - } + pd = STDOUT_FILENO; else if (!strcmp (type, "w")) - { - pd = STDIN_FILENO; - } + pd = STDIN_FILENO; else - { - return NULL; - } + return NULL; + if (pipe (fd) != -1) { switch (fork ()) { - case -1: - close (fd[0]); - close (fd[1]); - break; - case 0: - close (fd[0]); - if ((fd[1] == pd) || (dup2 (fd[1], pd) == pd)) - { - if (fd[1] != pd) - { - close (fd[1]); - } - execl ("/bin/sh", "sh", "-c", command, NULL); - close (pd); - } - exit (1); - break; - default: - close (fd[1]); - if (ret = fdopen (fd[0], type)) - { - return ret; - } - close (fd[0]); - break; + case -1: + close (fd[0]); + close (fd[1]); + break; + case 0: + close (fd[0]); + if ((fd[1] == pd) || (dup2 (fd[1], pd) == pd)) + { + if (fd[1] != pd) + { + close (fd[1]); + } + execl ("/bin/sh", "sh", "-c", command, NULL); + close (pd); + } + _exit (1); + break; + default: + close (fd[1]); + if (ret = fdopen (fd[0], type)) + { + return ret; + } + close (fd[0]); + break; } } return NULL; @@ -232,8 +221,6 @@ * String related function ****************************************************************************/ - - /* * A replacement of strdup(), since it's not defined at some * unix variants.