Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-10-05 06:29:46 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-05 06:29:46 +0400
commitca7320ac2c87ff6ccd0b03b14a6a81697534ed0f (patch)
tree2436d8f43c8e82c2792d91b9189da5ba4fb500e2 /winsup/testsuite
parentaf39152f4cdca60c18aa9c3a1fa9d1eea480d4f2 (diff)
* winsup.api/systemcall.c: New file. Check for system call problems.
Diffstat (limited to 'winsup/testsuite')
-rw-r--r--winsup/testsuite/ChangeLog4
-rw-r--r--winsup/testsuite/winsup.api/systemcall.c58
2 files changed, 62 insertions, 0 deletions
diff --git a/winsup/testsuite/ChangeLog b/winsup/testsuite/ChangeLog
index a08e413bb..610c532d3 100644
--- a/winsup/testsuite/ChangeLog
+++ b/winsup/testsuite/ChangeLog
@@ -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>
* libltp/lib/get_high_address.c (get_high_address): Get inaccessible
diff --git a/winsup/testsuite/winsup.api/systemcall.c b/winsup/testsuite/winsup.api/systemcall.c
new file mode 100644
index 000000000..8121b1277
--- /dev/null
+++ b/winsup/testsuite/winsup.api/systemcall.c
@@ -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);
+}