@@ -877,7 +877,12 @@ int test_file_stream(void)
877
877
return 0 ;
878
878
}
879
879
880
- int test_fork (void )
880
+ enum fork_type {
881
+ FORK_STANDARD ,
882
+ FORK_VFORK ,
883
+ };
884
+
885
+ int test_fork (enum fork_type type )
881
886
{
882
887
int status ;
883
888
pid_t pid ;
@@ -886,14 +891,23 @@ int test_fork(void)
886
891
fflush (stdout );
887
892
fflush (stderr );
888
893
889
- pid = fork ();
894
+ switch (type ) {
895
+ case FORK_STANDARD :
896
+ pid = fork ();
897
+ break ;
898
+ case FORK_VFORK :
899
+ pid = vfork ();
900
+ break ;
901
+ default :
902
+ return 1 ;
903
+ }
890
904
891
905
switch (pid ) {
892
906
case -1 :
893
907
return 1 ;
894
908
895
909
case 0 :
896
- exit (123 );
910
+ _exit (123 );
897
911
898
912
default :
899
913
pid = waitpid (pid , & status , 0 );
@@ -1330,7 +1344,7 @@ int run_syscall(int min, int max)
1330
1344
CASE_TEST (dup3_m1 ); tmp = dup3 (-1 , 100 , 0 ); EXPECT_SYSER (1 , tmp , -1 , EBADF ); if (tmp != -1 ) close (tmp ); break ;
1331
1345
CASE_TEST (execve_root ); EXPECT_SYSER (1 , execve ("/" , (char * []){ [0 ] = "/" , [1 ] = NULL }, NULL ), -1 , EACCES ); break ;
1332
1346
CASE_TEST (file_stream ); EXPECT_SYSZR (1 , test_file_stream ()); break ;
1333
- CASE_TEST (fork ); EXPECT_SYSZR (1 , test_fork ()); break ;
1347
+ CASE_TEST (fork ); EXPECT_SYSZR (1 , test_fork (FORK_STANDARD )); break ;
1334
1348
CASE_TEST (getdents64_root ); EXPECT_SYSNE (1 , test_getdents64 ("/" ), -1 ); break ;
1335
1349
CASE_TEST (getdents64_null ); EXPECT_SYSER (1 , test_getdents64 ("/dev/null" ), -1 , ENOTDIR ); break ;
1336
1350
CASE_TEST (directories ); EXPECT_SYSZR (proc , test_dirent ()); break ;
@@ -1374,6 +1388,7 @@ int run_syscall(int min, int max)
1374
1388
CASE_TEST (uname_fault ); EXPECT_SYSER (1 , uname (NULL ), -1 , EFAULT ); break ;
1375
1389
CASE_TEST (unlink_root ); EXPECT_SYSER (1 , unlink ("/" ), -1 , EISDIR ); break ;
1376
1390
CASE_TEST (unlink_blah ); EXPECT_SYSER (1 , unlink ("/proc/self/blah" ), -1 , ENOENT ); break ;
1391
+ CASE_TEST (vfork ); EXPECT_SYSZR (1 , test_fork (FORK_VFORK )); break ;
1377
1392
CASE_TEST (wait_child ); EXPECT_SYSER (1 , wait (& tmp ), -1 , ECHILD ); break ;
1378
1393
CASE_TEST (waitpid_min ); EXPECT_SYSER (1 , waitpid (INT_MIN , & tmp , WNOHANG ), -1 , ESRCH ); break ;
1379
1394
CASE_TEST (waitpid_child ); EXPECT_SYSER (1 , waitpid (getpid (), & tmp , WNOHANG ), -1 , ECHILD ); break ;
0 commit comments