94 int r;
95 struct stat statb;
96 sigset_t newset;
97 sigset_t oldset;
98
99 *file_locked = 0;
100 if (timeout <= 0) {
101 timeout = 120;
102 }
103 for (;;) {
104 BLOCK_INTERUPTS;
105 r = symlink(name, lockname);
106 if (r == 0) {
107 *file_locked = 1;
108 UNBLOCK_INTERUPTS;
109 return 0; /* success */
110 }
111 UNBLOCK_INTERUPTS;
112
113 if (errno != EEXIST) {
114 file_lock_error(msg, name, NOCATGETS("symlink(%s, %s)"),
115 (int) name, (int) lockname);
116 fprintf(stderr, "%s", msg);
117 return errno;
118 }
119
120 counter = 0;
121 for (;;) {
122 sleep(1);
123 r = lstat(lockname, &statb);
124 if (r == -1) {
125 /*
126 * The lock must have just gone away - try
127 * again.
128 */
129 break;
130 }
131
132 if ((counter > 5) && (!printed_warning)) {
133 /* Print waiting message after 5 secs */
134 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
|
94 int r;
95 struct stat statb;
96 sigset_t newset;
97 sigset_t oldset;
98
99 *file_locked = 0;
100 if (timeout <= 0) {
101 timeout = 120;
102 }
103 for (;;) {
104 BLOCK_INTERUPTS;
105 r = symlink(name, lockname);
106 if (r == 0) {
107 *file_locked = 1;
108 UNBLOCK_INTERUPTS;
109 return 0; /* success */
110 }
111 UNBLOCK_INTERUPTS;
112
113 if (errno != EEXIST) {
114 file_lock_error(msg, name, (char *)NOCATGETS("symlink(%s, %s)"),
115 (int) name, (int) lockname);
116 fprintf(stderr, "%s", msg);
117 return errno;
118 }
119
120 counter = 0;
121 for (;;) {
122 sleep(1);
123 r = lstat(lockname, &statb);
124 if (r == -1) {
125 /*
126 * The lock must have just gone away - try
127 * again.
128 */
129 break;
130 }
131
132 if ((counter > 5) && (!printed_warning)) {
133 /* Print waiting message after 5 secs */
134 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
|