You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (SEM_FAILED==(sem=sem_open(sem_name, O_CREAT|O_EXCL, S_IWUSR|S_IRUSR, 1)))
274
+
if (-1==ft_sem_create(sem_name, &wrapper_sem))
275
275
{
276
-
perror("faketime: sem_open");
277
-
fprintf(stderr, "The faketime wrapper only works on platforms that support the sem_open()\nsystem call. However, you may LD_PRELOAD libfaketime without using this wrapper.\n");
276
+
perror("faketime: ft_sem_create");
277
+
fprintf(stderr, "The faketime wrapper failed to create its lock.\nHowever, you may LD_PRELOAD libfaketime without using this wrapper.\n");
278
278
exit(EXIT_FAILURE);
279
279
}
280
280
281
281
/* create shm */
282
282
if (-1== (shm_fd=shm_open(shm_name, O_CREAT|O_EXCL|O_RDWR, S_IWUSR|S_IRUSR)))
283
283
{
284
284
perror("faketime: shm_open");
285
-
if (-1==sem_unlink(argv[2]))
286
-
{
287
-
perror("faketime: sem_unlink");
288
-
}
285
+
ft_sem_unlink(&wrapper_sem);
289
286
exit(EXIT_FAILURE);
290
287
}
291
288
292
289
/* set shm size */
293
-
if (-1==ftruncate(shm_fd, sizeof(uint64_t)))
290
+
if (-1==ftruncate(shm_fd, sizeof(structft_shared_s)))
294
291
{
295
292
perror("faketime: ftruncate");
296
293
cleanup_shobjs();
@@ -306,22 +303,26 @@ int main (int argc, char **argv)
306
303
exit(EXIT_FAILURE);
307
304
}
308
305
309
-
if (sem_wait(sem) ==-1)
306
+
if (ft_sem_lock(&wrapper_sem) ==-1)
310
307
{
311
-
perror("faketime: sem_wait");
308
+
perror("faketime: ft_sem_lock");
312
309
cleanup_shobjs();
313
310
exit(EXIT_FAILURE);
314
311
}
315
312
316
313
/* init elapsed time ticks to zero */
317
314
ft_shared->ticks=0;
318
315
ft_shared->file_idx=0;
319
-
ft_shared->start_time.real.tv_sec=0;
320
-
ft_shared->start_time.real.tv_nsec=-1;
321
-
ft_shared->start_time.mon.tv_sec=0;
322
-
ft_shared->start_time.mon.tv_nsec=-1;
323
-
ft_shared->start_time.mon_raw.tv_sec=0;
324
-
ft_shared->start_time.mon_raw.tv_nsec=-1;
316
+
ft_shared->start_time_real.sec=0;
317
+
ft_shared->start_time_real.nsec=-1;
318
+
ft_shared->start_time_mon.sec=0;
319
+
ft_shared->start_time_mon.nsec=-1;
320
+
ft_shared->start_time_mon_raw.sec=0;
321
+
ft_shared->start_time_mon_raw.nsec=-1;
322
+
#ifdefCLOCK_BOOTTIME
323
+
ft_shared->start_time_boot.sec=0;
324
+
ft_shared->start_time_boot.nsec=-1;
325
+
#endif
325
326
326
327
if (-1==munmap(ft_shared, (sizeof(structft_shared_s))))
327
328
{
@@ -330,16 +331,16 @@ int main (int argc, char **argv)
0 commit comments