sprintf ( ovrfile, "%s/%s.png", iconpath, app -> unique_id );
+ // making sure the file is at least a few seconds old, to help avoid race condition
struct stat statbuf;
- if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ if ( stat ( ovrfile, &statbuf ) == 0 && time ( NULL ) - statbuf.st_mtime > 5 ) { // race with pndnotifyd
buflen = statbuf.st_size;
if ( ( iconbuf = malloc ( statbuf.st_size ) ) ) {
int fd = open ( ovrfile, O_RDONLY );