Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
test_execve.c
Package: mysql-3.23.35.tar.gz [view]
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 1k
Category:
MySQL
Development Platform:
Visual C++
- /* ==== test_execve.c ============================================================
- * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test execve() and dup2() calls.
- *
- * 1.00 94/04/29 proven
- * -Started coding this file.
- */
- #define PTHREAD_KERNEL
- #include <pthread.h>
- #include <string.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdio.h>
- extern char **environ;
- char *argv[] = {
- "/bin/echo",
- "This message should be displayed after the execve system call",
- NULL
- };
- char * should_succeed = "This line should be displayedn";
- char * should_fail = "Error: This line should NOT be displayedn";
- main()
- {
- pthread_t thread;
- int fd;
- pthread_init();
- printf("This is the first messagen");
- if (isatty(1)) {
- if ((fd = open(ttyname(1), O_RDWR)) < OK) {
- printf("Error: opening ttyn");
- exit(1);
- }
- } else {
- printf("Error: stdout not a ttyn");
- exit(1);
- }
- printf("This output is necessary to set the stdout fd to NONBLOCKINGn");
- /* do a dup2 */
- dup2(fd, 1);
- write(1, should_succeed, (size_t)strlen(should_succeed));
- machdep_sys_write(1, should_fail, strlen(should_fail));
- if (execve(argv[0], argv, environ) < OK) {
- printf("Error: execven");
- exit(1);
- }
- PANIC();
- }