problem closing stdout - VxWorks
This is a discussion on problem closing stdout - VxWorks ; Hi EveryOne: I am New to vxworks.I am trying to get the list of files in the directories using ls() and i want to redirect ls() > to a pipe so i am closing the stdout file descriptor and duplicating ...
| | LinkBack | Tools |
|
#1
| |||
| |||
| I am New to vxworks.I am trying to get the list of files in the directories using ls() and i want to redirect ls() > to a pipe so i am closing the stdout file descriptor and duplicating pipe fileDescriptor.But the pbm im facing is when execution comes to line close(1) my simulator gets hanged. I m working in workBench 2.5 . Can anyone give me some suggestions. |
|
#2
| |||
| |||
| On Aug 14, 5:09 pm, senthil > Hi EveryOne: > I am New to vxworks.I am trying to get the > list of files in the directories using ls() and i want to redirect > ls() > to a pipe so i am closing the stdout file descriptor and > duplicating pipe fileDescriptor.But the pbm im facing is when > execution comes to line close(1) my simulator gets hanged. > > I m working in workBench 2.5 . > > Can anyone give me some suggestions. In VxWorks the File descriptors are shared and accessible across tasks. So, it is quite possible that the FD stdout that was closed was being used by some other task. In general, closing the stdin, stdout and stderr is not recommended. Now, coming to redirection of the output - there are specific APIs that would help you achieve this - 1) iosTaskStdSet( ) - set the file descriptor for task standard input/ output/error void ioTaskStdSet ( int taskId, /* task whose std fd is to be set (0 = self) */ int stdFd, /* std input (0), output (1), or error (2) */ int newFd /* new underlying file descriptor */ ) 2) ioGlobalStdSet( ) - set the file descriptor for global standard input/output/error int ioGlobalStdGet ( int stdFd /* std input (0), output (1), or error (2) */ ) Hope this would help you! Regards, Sriram. |
|
#3
| |||
| |||
| Thanx for ur suggestions. I tried it now i am able to redirect stdout to pipe. is there any way after doing some process (in same Task) can i get back the redirected file descriptor to standard output. |
|
#4
| |||
| |||
| On Aug 16, 9:47 am, senthil > Thanx for ur suggestions. Well, sorry, I was slightly wrong with the API descriptions earlier. Please find them corrected below - The two APIs related to redirecting the standard input, output and error are as below - 1) ioTaskStdSet( ) - set the file descriptor for task standard input/ output/error void ioTaskStdSet ( int taskId, /* task whose std fd is to be set (0 = self) */ int stdFd, /* std input (0), output (1), or error (2) */ int newFd /* new underlying file descriptor */ ) 2) ioGlobalStdSet( ) - set the file descriptor for global standard input/output/error void ioGlobalStdSet ( int stdFd, /* std input (0), output (1), or error (2) */ int newFd /* new underlying file descriptor */ ) > I tried it now i am able to redirect stdout to pipe. I assume that you had used the correct form of the API while you were able to successfully redirect the stdout to pipe. > is there any way after doing some process (in same Task) can i get > back the redirected file descriptor to standard output. Yes, you can retrieve and store the current file descriptor that denotes the stdout before redirection. Once you are done with the needed processing, you can set back the stdout to the file descriptor that you had stored earlier. The current file descriptor that denote the stdout can be obtained by using the following APIs - 1) ioTaskStdGet( ) - get the file descriptor for task standard input/ output/error int ioTaskStdGet ( int taskId, /* ID of desired task (0 = self) */ int stdFd /* std input (0), output (1), or error (2) */ ) 2) ioGlobalStdGet( ) - get the file descriptor for global standard input/output/error int ioGlobalStdGet ( int stdFd /* std input (0), output (1), or error (2) */ ) Let us consider an example below - int pipeFd = 10; int prevStdOut = ioTaskStdGet(0, 1); /* Retrieve and store (backup) the current stdout file descriptor */ if(prevStdOut != ERROR) { ioTaskStdSet(0, 1, pipeFd); /* Redirect the stdout to the pipe device */ .... .... /* Do some processing */ .... ioTaskStdSet(0, 1, prevStdOut); /* Restore the stdout to what it was earlier */ } Hope this answered your query! Regards, Sriram. |
|
#5
| |||
| |||
| Hai Thanx for ur suggestions. I tried it now i am able to get back STDOUT back to my task. |
« Previous Thread
|
Next Thread »
| Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tab closing problem | unix | Mozilla | 10 | 01-15-2008 12:13 PM |
| AIX 5.1 cdrom install on p690 lpar hangs at "closing stdin and stdout" | unix | Aix | 2 | 10-21-2007 12:12 AM |
| class CastException closing connection ( closing Clob) | unix | Weblogic | 0 | 10-09-2007 09:33 PM |
| Re: Tomcat problem - in closing | unix | FreeBSD | 0 | 06-02-2006 07:52 PM |
| Tomcat problem - in closing | unix | FreeBSD | 0 | 06-01-2006 09:00 AM |
All times are GMT. The time now is 09:11 PM.
