File tree 2 files changed +20
-8
lines changed 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,11 @@ static void sigpipe_handler(int signo)
201
201
watch_quit ();
202
202
}
203
203
204
+ static void atexit_handler (void )
205
+ {
206
+ syslog (LOG_INFO , "exiting" );
207
+ }
208
+
204
209
int main (int argc , char * * argv )
205
210
{
206
211
int flags ;
@@ -216,7 +221,8 @@ int main(int argc, char **argv)
216
221
if (!username )
217
222
username = "nobody" ;
218
223
219
- openlog ("cdba-server" , 0 , LOG_DAEMON );
224
+ openlog ("cdba-server" , LOG_PID , LOG_DAEMON );
225
+ atexit (atexit_handler );
220
226
221
227
ret = device_parser (".cdba" );
222
228
if (ret ) {
Original file line number Diff line number Diff line change @@ -64,15 +64,21 @@ static void device_lock(struct device *device)
64
64
if (fd < 0 )
65
65
err (1 , "failed to open lockfile %s" , lock );
66
66
67
- n = flock (fd , LOCK_EX | LOCK_NB );
68
- if (!n )
69
- return ;
67
+ while (1 ) {
68
+ char c ;
69
+
70
+ n = flock (fd , LOCK_EX | LOCK_NB );
71
+ if (!n )
72
+ return ;
70
73
71
- warnx ("board is in use, waiting..." );
74
+ warnx ("board is in use, waiting..." );
72
75
73
- n = flock (fd , LOCK_EX );
74
- if (n < 0 )
75
- err (1 , "failed to lock lockfile %s" , lock );
76
+ sleep (3 );
77
+
78
+ /* check that connection isn't gone */
79
+ if (read (STDIN_FILENO , & c , 1 ) == 0 )
80
+ errx (1 , "connection is gone" );
81
+ }
76
82
}
77
83
78
84
static bool device_check_access (struct device * device ,
You can’t perform that action at this time.
0 commit comments