~3v1n0/upstart/activation-proper-dbus-path

« back to all changes in this revision

Viewing changes to test/test_util_common.c

  • Committer: Dimitri John Ledkov
  • Date: 2014-07-11 16:36:49 UTC
  • mfrom: (1638.1.18 shrink-notifications)
  • Revision ID: dimitri.ledkov@canonical.com-20140711163649-pc5w3umcv32brdz5
Merge race fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
375
375
 *
376
376
 * Simplified waitpid(2) with timeout using a pipe to allow select(2)
377
377
 * with timeout to be used to wait for process state change.
 
378
 *
 
379
 * Returns: as waitpid(2).
378
380
 **/
379
381
pid_t
380
382
timed_waitpid (pid_t pid, time_t timeout)
1000
1002
                        nih_local char *cmd = NULL;
1001
1003
 
1002
1004
                        /* Clean up if tests forgot to */
1003
 
                        cmd = NIH_MUST (nih_sprintf (NULL, "rm %s/*.session 2>/dev/null", path));
 
1005
                        cmd = NIH_MUST (nih_sprintf (NULL, "rm -f %s/*.session 2>/dev/null", path));
1004
1006
                        assert0 (system (cmd));
1005
1007
 
1006
1008
                        /* Remove the directory tree the first Session Init created */
1094
1096
                                buffer->buf + buffer->len,
1095
1097
                                buffer->size - buffer->len);
1096
1098
 
1097
 
                if (len <= 0)
1098
 
                        break;
1099
 
                else if (len > 0)
 
1099
                if (len < 0 && errno != EAGAIN && errno != EINTR) {
 
1100
                        break;
 
1101
                } else if (! len) {
 
1102
                        break;
 
1103
                } else if (len > 0) {
1100
1104
                        buffer->len += len;
 
1105
                }
1101
1106
        }
1102
1107
 
1103
1108
        close (fd);