mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 02:50:25 +08:00
* winsup.api/systemcall.c: New file. Check for system call problems.
This commit is contained in:
parent
af39152f4c
commit
ca7320ac2c
@ -1,3 +1,7 @@
|
|||||||
|
Thu Oct 4 22:19:39 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* winsup.api/systemcall.c: New file. Check for system call problems.
|
||||||
|
|
||||||
2001-09-20 Egor Duda <deo@logos-m.ru>
|
2001-09-20 Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
* libltp/lib/get_high_address.c (get_high_address): Get inaccessible
|
* libltp/lib/get_high_address.c (get_high_address): Get inaccessible
|
||||||
|
58
winsup/testsuite/winsup.api/systemcall.c
Normal file
58
winsup/testsuite/winsup.api/systemcall.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int fd, pid, n;
|
||||||
|
int fds[2];
|
||||||
|
static char buf[4096];
|
||||||
|
|
||||||
|
close (1);
|
||||||
|
if ((fd = open ("/dev/null", O_WRONLY)) != 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "couldn't redirect stdout to /dev/null, fd %d - %s\n", fd, strerror ());
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
if (pipe (fds))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "pipe call failed - %s\n", strerror ());
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
if ((pid = fork ()) == 0)
|
||||||
|
{
|
||||||
|
close (fds[0]);
|
||||||
|
if (dup2 (fds[1], 2) != 2)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "couldn't redirect stderr to pipe - %s\n", strerror ());
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
exit (system ("ls"));
|
||||||
|
}
|
||||||
|
else if (pid < 0)
|
||||||
|
{
|
||||||
|
perror ("couldn't fork");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
close (fds[1]);
|
||||||
|
if (read (fds[0], buf, 4096) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "system call failed?\n%s\n", buf);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waitpid (pid, &n, 0) < 0)
|
||||||
|
{
|
||||||
|
perror ("waitpid failed");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
if (n != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "system() call returend %p\n", n);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
exit (0);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user