Hi group,
I have this suite of program that use threads and fork/exec calls.
The programs now run OK with a major problem, the problem is that
sftp does not flush the output file buffer in a timely matter.
Here is a general description of how things work:
- client starts thread to connect to server
- client starts sftp using pseudo ttys.
- client start thread to process sftp output
- client start thread to process console input
- client start thread to process server messages
- client waits for files names from server
- when filename comes in send, transfer request to sftp
- when sftp outputs it is done, call file processor with filename
- return to wait.
The problem is that the first filename is processed just fine. All the next filename get errors while being processed. If I add a sleep(1) delay before calling the file processor, everything works, but there is an added wait! This is a real time program and I can't afford the extra delay.
I tried adding a 'sync()', that did not help.
My question is, how can I force sftp to flush his buffer sooner??
Thanks for your time.