I am implementing an SMTP-sender in C which is supposed to read a file from a directory whenever it is created, process data and delete the file.
How can I implement this polling function which should keep doing this automatically?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple option is to run your program periodically from cron. The program can use the Linux API call readdir to iterate through a directory. It doesn’t have to actively monitor the directory.
Here’s a simple code example:
Disclaimer: For the sake of simplicity I did not include code to check or handle error conditons.