Boa Unable To Dup2 The Error Log Bad File Descriptor
Contents |
subject ] dup bad file descriptor [ author ] Hello, boa-0.94.14rc17 cannot write my error log: [13/Aug/2003:03:14:11 +0000] log.c:70 (open_logs) - unable to dup2 the error
Grep Standard Input Bad File Descriptor
log: Bad file descriptor /var/log/error_log is a file in ramfs and this has always worked.. until now. How can I fix this? Thanks for your help, Uwe Previous message: [uClinux-dev] XIP Next message: [uClinux-dev] blackfin ? Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] More information about the uClinux-dev mailing list
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Bash Bad File Descriptor
and policies of this site About Us Learn more about Stack Overflow dup2 bad file descriptor c the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags cat standard output bad file descriptor Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://mailman.uclinux.org/pipermail/uclinux-dev/2003-August/020399.html takes a minute: Sign up dup2 bad file descriptor up vote 0 down vote favorite I am trying to implement pipe to my shell. Right now it can handle normal commands like ls, who, date etc.. By reading a lot and going in to other stack overflow posts to check how pipe is supposed to work i have come up http://stackoverflow.com/questions/34009794/dup2-bad-file-descriptor with this code that i will demonstrate for you guys. The function basically takes in a command that is should process. void runCommand(Command *cmd){ char **pl = cmd->pgm->pgmlist; int status; Pgm *p = cmd->pgm; //Count the number of pipes and create the right number of filedescriptors int numPipes = countPipes(cmd->pgm); int pipefds[2*numPipes]; //Pipe the file descriptors here and check if there was an error. for(int i = 0; i < (numPipes); i++){ if(pipe(pipefds + i*2) < 0) { perror("couldn't pipe"); exit(EXIT_FAILURE); } } pid_t pid, wpid; int fdr; int fd; int j = 0; while(p != NULL) { pid = fork(); if (pid == 0) { // Child process if (cmd->bakground == 1) // Check if it should be running in the background, if so, assign a new PID { setpgid(pid, 0); } // Check if RSTDOUT is on or not if(cmd->rstdout != NULL){ fd = open(cmd->rstdout, O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR); //fclose(fopen(cmd->rstdout, "w")); printf("in first\n"); dup2(fd,1); close(fd); } // Check if RSTIN is on or not if(cmd->rstdin != NULL) { fdr
uclinux arm s3c4510b process Being ported to Boa-0.94.13 uclinux, a few notes to share with you. Compile a linux c system, including morphology and syntax analysis module for Linux on bison and flex. yacc is a grammar parser generator bison that is the GNU version of yacc and lex and yacc are http://m.blog.csdn.net/article/details?id=51193321 tools used to construct the lexical analyzer and syntax interpreter, Lex and Yacc, you can easily construct a grammar explanations. 1 Extract the Boa-0.94.13.tar.gz, into the boa-0.94.13/src Catalog 2 .. / configure Enter http://m.blog.chinaunix.net/uid-30510400-id-5386094.html generate Makefile Began to make a Error 1: debian :/ home/a/boa-0.94.13/src # make yacc-d boa_grammar.y make: yacc: Command not found make: *** [y.tab.c] Error 127 Solution: debian :/ home/a/boa-0.94.13/src # apt-get install bad file bison Error 2: debian :/ home/a/boa-0.94.13/src # make lex boa_lexer.l to make: lex: Command not found make: *** [lex.yy.c] Error 127 Solution: debian :/ home/a/boa-0.94.13/src # apt-get install flex Error 3: debian :/ home/a/sss/boa-0.94.13/src # make gcc-g-O2-pipe-Wall-I.-c-o util.o util.c util.c: 100:1: error: pasting "t" and "->" does not give a valid preprocessing token make: *** [util.o] Error 1 Solution: Modify the src / compat.h Find # bad file descriptor Define TIMEZONE_OFFSET (foo) foo # # -> tm_gmtoff Modified # Define TIMEZONE_OFFSET (foo) (foo) -> tm_gmtoff Then debian :/ home/a/sss/boa-0.94.13/src # make clean debian :/ home/a/sss/boa-0.94.13/src # make But there is a warning: request.c: In funtion 'get_request': request.c: 84: warning: pointer targets in passing argument 3 of 'accept' differ in signedness Looked unhappy, it does not matter To 84 look request.c. int accept (int socket, struct sockaddr * address, size_t * address_len) prototype. Where the parameter type is wrong. Int to size_t on it. debian :/ home/a/sss/boa-0.94.13/src # make Basically there is no problem. However, when running boa, running, ps this process Solution: Written off if (setuid (0)! = -1) { DIE ("icky Linux kernel bug!"); } Can be a recompile. Generated boa tested on a PC no problem -------------------------------------------------- -------------------- This is at the forum to share, I just started testing have not encountered .... hope to be useful (2) modify the src / log.c Comment out if (dup2 (error_log, STDERR_FILENO) == -1) { DIE ("unable to dup2 the error log"); } As follows: Otherwise, an error occurs: log.c: 73 unable to dup2 the error log: bad file descriptor (3) modify the src / boa.
我所用的环境是在ubuntu12下,交叉编译工具arm-none-linux-gnueabi-gcc(arm-linux-gcc-4.4.3.tar.gz),运行板子安卓手机(最好是烧的android debug版,这样有root权限操作较为方便一些); 结合网上一些教程结合自己的移植过程中遇到的问题,贴出来;编译之前需要安装bison和flex,这两个工具用,sudo apt-get install就可以安装了; 1.下载Boa源码 下载地址: http://www.boa.org/ 最新发行版本: 0.94.13 下载 boa-0.94.13.tar.gz 解压:# tar xzf boa-0.94.13.tar.gz 2.修改一些头文件 (1)修改 src/compat.h 找到 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff修改成#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff 否则会出现错误: util.c:100:1: error: pasting "t" and "->" does not give a valid preprocessing token make: *** [util.o] 错误 1 (2)修改 src/log.c 注释掉 if (dup2(error_log, STDERR_FILENO) == -1) { DIE("unable to dup2 the error log"); } 为: /*if (dup2(error_log, STDERR_FILENO) == -1) { DIE("unable to dup2 the error log"); }*/ 否则会出现错误: log.c:73 unable to dup2 the error log:bad file descriptor (3)修改src/boa.c 注释掉下面两句话: if (passwdbuf == NULL) { DIE(”getpwuid”); } if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) { DIE(”initgroups”); } 为 #if 0 if (passwdbuf == NULL) { DIE(”getpwuid”); } if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) { DIE(”initgroups”); } #endif 否则会出现错误:boa.c:211 - getpwuid: No such file or directory 注释掉下面语句: if (setuid(0) != -1) { DIE(”icky Linux kernel bug!”); } 为 #if 0 if (setuid(0) != -1) { DIE(”icky Linux kernel bug!”); } #endif 否则会出现问题:boa.c:228 - icky Linux kernel bug!: No such file or directory 3、生成Makefile文件 执行: #cd boa-0.94.13/src #./configure 4、修改Makefile 在 boa-0.94.13/src目录下修改Makefile vim Makefile 找到CC,CPP,并添加AR,LD,STRIP,如下 CC = arm-none-linux-gnueabi-gcc CPP = arm-none-linux-gnueabi-gcc -E AR = arm-none-linux-gnueabi-ar LD = arm-none-linux-gnueabi-ld STRIP = arm-none-linux-gnueabi-strip 找到生成boa和boa_ind