File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Expand file tree Collapse file tree 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)
201201 watch_quit ();
202202}
203203
204+ static void atexit_handler (void )
205+ {
206+ syslog (LOG_INFO , "exiting" );
207+ }
208+
204209int main (int argc , char * * argv )
205210{
206211 int flags ;
@@ -216,7 +221,8 @@ int main(int argc, char **argv)
216221 if (!username )
217222 username = "nobody" ;
218223
219- openlog ("cdba-server" , 0 , LOG_DAEMON );
224+ openlog ("cdba-server" , LOG_PID , LOG_DAEMON );
225+ atexit (atexit_handler );
220226
221227 ret = device_parser (".cdba" );
222228 if (ret ) {
Original file line number Diff line number Diff line change @@ -64,15 +64,21 @@ static void device_lock(struct device *device)
6464 if (fd < 0 )
6565 err (1 , "failed to open lockfile %s" , lock );
6666
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 ;
7073
71- warnx ("board is in use, waiting..." );
74+ warnx ("board is in use, waiting..." );
7275
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+ }
7682}
7783
7884static bool device_check_access (struct device * device ,
You can’t perform that action at this time.
0 commit comments