********************************
Following is not the real issue. The issue is with popen.
Plz continue forward with the thread to get a better picture.
********************************
Hi,
I am working on a customised ftp application. In it we have used sprintf to store a UNIX command like "ls *test" to a temporary variable to execute it on the server and return the result to the client. However the sprintf and snprintf is not working properly. The following code segment will give an idea.
It seems I have found where the problem is. The problem is not with the assignment statement as stated above. It is in a call to popen. After calling popen as
fin = popen (line, "r");
the value of line gets truncated.
Is there some issue with popen in Solaris? I have searched the man pages but could not find anything.
The problem is not supposed to be with popen. popen is a standard function and I do not think that it will modify the value of "line". It must be getting modified somewhere else somehow. The value of line is perfect just before popen. Just after popen it is changed. Any idea how i can find how it is getting changed?
Also, the behaviour of the application is strange. Sometimes the client - server link gets disconnected after the first 'ls' when we try another 'ls'. Sometimes it happens only after we give a 'cd' command followed by a 'ls' command.
Sorry, I didn't get time to look into the real issue.
After putting some debugging logs I found that popen is throwing "Bad file number" error on the first call with "/bin/ls -l" as the argument. On the second call it throws "No child processes". (By throws I mean it sets the value at errno).
Another strange behaviour is that after a put command the error thrown is "Illegal seek".
I would like to point it out here that all these error are in Solaris only. The same application is being compiled for AIX also. There it is working just fine.
Can the problem be related to the makefile? The application uses a very complex makefile to compile. Can the problem be due to wrong way of compiling (if there is any such thing)? It uses a lot of custom made libraries. The libraries are well tested and should not have any errors in it.