Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am running number of processes using rc script on an embedded system ONT(Optical network terminal).
I have developed a packet sniffer application which captures RTP/RTCP packets on the network.
I am adding this process into rc script(onuInit) file for starting my application with other process while initing the board.
The problem comes now. I will not be able to see any printf traces which I supposed to print in packet-recorder application whenever I start capture, while other process are able to print the traces happily.
All the process are getting started as deamon(using fork) and my application too.
The strange thing here is I am able to see the printf traces in my application while init process completes, which is before a infinite while loop inside the message-handler thread which is reading the messages on queue, and once it reaches to the while loop it stops printind further traces. I am using msgrcv and checking for the number of bytes it read from the queue, if it is more than 0 then I process the message or else sleep for some time and try to read the queue again.
Now one more thing here if I kill my packet-recorder application and re-start it manually then I will be able to see my all printf traces
I have tried the following:
1) Bring–up the processes in different order.
2) Checked the stdin, stdout, stderr values (they all are fine and showing as 0, 1, 2).
3) ‘write’ is not working as it uses stdout.
4) File-writing fwrite and fprintf(both are working fine).
5) used _exit(0) instead exit(0).
Please can you suggest what can be the possible issues here.
I will be pleased to elaborate the issue if u find it non-understandable somewhere.
I am running number of processes using rc script on an embedded system ONT(Optical network terminal).
I have developed a packet sniffer application which captures RTP/RTCP packets on the network.
I am adding this process into rc script(onuInit) file for starting my application with other process while initing the board.
The problem comes now. I will not be able to see any printf traces which I supposed to print in packet-recorder application whenever I start capture, while other process are able to print the traces happily.
All the process are getting started as deamon(using fork) and my application too.
The strange thing here is I am able to see the printf traces in my application while init process completes, which is before a infinite while loop inside the message-handler thread which is reading the messages on queue, and once it reaches to the while loop it stops printind further traces. I am using msgrcv and checking for the number of bytes it read from the queue, if it is more than 0 then I process the message or else sleep for some time and try to read the queue again.
Now one more thing here if I kill my packet-recorder application and re-start it manually then I will be able to see my all printf traces
I have tried the following:
1) Bring–up the processes in different order.
2) Checked the stdin, stdout, stderr values (they all are fine and showing as 0, 1, 2).
3) ‘write’ is not working as it uses stdout.
4) File-writing fwrite and fprintf(both are working fine).
5) used _exit(0) instead exit(0).
Please can you suggest what can be the possible issues here.
I will be pleased to elaborate the issue if u find it non-understandable somewhere.
Thanks in advance.
It;s likely that in "normal mode" process's stdout redirected somewhere
You can start system, find your procss id and then
I checked the fds of my process and it shows as below:
I241GA(a0adc9ea)# ls -l /proc/649/fd/
lrwx------ 1 root root 64 Jan 1 00:52 0 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 1 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 2 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 3 -> /var/alcatel/captur
elog/c11-struct-file
and for the other process it shows:
lrwx------ 1 root root 64 Jan 1 00:53 0 -> /dev/ttyS0
l-wx------ 1 root root 64 Jan 1 00:53 1 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 2 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 3 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 4 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 5 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 6 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 7 -> /tmp/PalIptkFifo
I am not able to see anythinf in /dev/ttyS0 file.
I am not sure whether we can redirect my process output to some /tmp/xyz.
If we can then please can you suggest how we can do it..
I checked the fds of my process and it shows as below:
I241GA(a0adc9ea)# ls -l /proc/649/fd/
lrwx------ 1 root root 64 Jan 1 00:52 0 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 1 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 2 -> /dev/ttyS0
lrwx------ 1 root root 64 Jan 1 00:52 3 -> /var/alcatel/captur
elog/c11-struct-file
and for the other process it shows:
lrwx------ 1 root root 64 Jan 1 00:53 0 -> /dev/ttyS0
l-wx------ 1 root root 64 Jan 1 00:53 1 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 2 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 3 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 4 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 5 -> /tmp/fifo
l-wx------ 1 root root 64 Jan 1 00:53 6 -> /tmp/error
l-wx------ 1 root root 64 Jan 1 00:53 7 -> /tmp/PalIptkFifo
I am not able to see anythinf in /dev/ttyS0 file.
I am not sure whether we can redirect my process output to some /tmp/xyz.
If we can then please can you suggest how we can do it..
Regards,
shiv
/dev/ttyS0 is not file, it's serial port device
Looks like your system uses serial port for communication.
How do you login to this system to run this ls program, ssh, or some other method ?
We are not using ssh for login. Infact our ONT(Optical network Terminal) does not require any login password. We can create user-name & password but did not create because it is not needed here.
One more thing I observed, even I start my packet-recorder process using command-Line instead running while initing ONT through rc script, it gives the same result for 'ls -l /proc/PID/fds'.
We are not using ssh for login. Infact our ONT(Optical network Terminal) does not require any login password. We can create user-name & password but did not create because it is not needed here.
One more thing I observed, even I start my packet-recorder process using command-Line instead running while initing ONT through rc script, it gives the same result for 'ls -l /proc/PID/fds'.
No I did not try it.
Actually I need to install strace utility.
I m trying to cross-compile strace for MVL.
I will analyse and share you the results once
I will run it for my process.
Hi Valery,
I am facing issue while cross-compiling strace for MVL.
It is not getting configured if I set CC compiler as /vobs/montavista/pro/devkit/ppc/82xx/bin/ppc_82xx-gcc.
So not able to get any logs for strace. but is printf uses any system call because it is an C library function.
Hi Valery,
I am facing issue while cross-compiling strace for MVL.
It is not getting configured if I set CC compiler as /vobs/montavista/pro/devkit/ppc/82xx/bin/ppc_82xx-gcc.
So not able to get any logs for strace. but is printf uses any system call because it is an C library function.
Yes, printf uses system call (write).
There are a lot of functions in the libc, that are only wrapper around syscals
Hmm...
I tried to use write explicitly and that also did not worked for me.
Today I was able to compile strace for MVL but getting the following error.
"__uClibc_start_main" this is because strace is not getting compiled with ld-cUlibc.so.0 and libc.so.0, I will try to include as library while compiling today.
Hi All,
I tried to include the shared libraries mentioned above but not able to resolve the above error.
Can you please suggest me what can be the issue with strace throwing this error?
And do I need to check some more things which may cause to hide print outputs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.