Home | History | Annotate | Download | only in execle
      1 /*
      2  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
      3  *    AUTHOR		: William Roske
      4  *    CO-PILOT		: Dave Fenner
      5  *    DATE STARTED	: 06/01/02
      6  * Copyright (C) 2015 Cyril Hrubis <chrubis (at) suse.cz>
      7  *
      8  * This program is free software; you can redistribute it and/or modify it
      9  * under the terms of version 2 of the GNU General Public License as
     10  * published by the Free Software Foundation.
     11  *
     12  * This program is distributed in the hope that it would be useful, but
     13  * WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     15  *
     16  * Further, this software is distributed without any warranty that it is
     17  * free of the rightful claim of any third person regarding infringement
     18  * or the like.  Any license provided herein, whether implied or
     19  * otherwise, applies only to this software file.  Patent licenses, if
     20  * any, provided herein do not apply to combinations of this program with
     21  * other software, or any other product whatsoever.
     22  *
     23  * You should have received a copy of the GNU General Public License along
     24  * with this program; if not, write the Free Software Foundation, Inc.,
     25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     26  *
     27  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
     28  * Mountain View, CA  94043, or:
     29  *
     30  * http://www.sgi.com
     31  *
     32  * For further information regarding this notice, see:
     33  *
     34  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
     35  */
     36 #include <sys/types.h>
     37 #include <sys/wait.h>
     38 #include <errno.h>
     39 #include <signal.h>
     40 #include <stdlib.h>
     41 #include <string.h>
     42 
     43 #include "test.h"
     44 
     45 static void setup(void);
     46 
     47 char *TCID = "execle01";
     48 int TST_TOTAL = 1;
     49 
     50 int main(int ac, char **av)
     51 {
     52 	int lc;
     53 	pid_t pid;
     54 	char *env[] = { "LTP_TEST_ENV_VAR=test", NULL };
     55 	char path[2048];
     56 
     57 	tst_parse_opts(ac, av, NULL, NULL);
     58 
     59 	setup();
     60 
     61 	if (tst_get_path("execle01_child", path, sizeof(path)))
     62 		tst_brkm(TCONF, NULL, "Couldn't find execle01_child in $PATH");
     63 
     64 	for (lc = 0; TEST_LOOPING(lc); lc++) {
     65 		switch (pid = FORK_OR_VFORK()) {
     66 		case 0:
     67 			execle(path, "execle01_child", "canary", NULL, env);
     68 			tst_brkm(TFAIL | TERRNO, NULL,
     69 			         "Failed to execute execl01_child");
     70 		case -1:
     71 			tst_brkm(TBROK | TERRNO, NULL, "fork failed");
     72 		default:
     73 			tst_record_childstatus(NULL, pid);
     74 		}
     75 	}
     76 
     77 	tst_exit();
     78 }
     79 
     80 void setup(void)
     81 {
     82 	tst_sig(FORK, DEF_HANDLER, NULL);
     83 
     84 	TEST_PAUSE;
     85 }
     86