1313
1414#include <dirent.h>
1515#include <signal.h>
16- #include <sys/stat.h>
1716#include <unistd.h>
1817
1918#include "utils/file.h"
@@ -423,8 +422,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
423422 /* complain every fifth interval */
424423 if ((ntries % LOG_FREQ ) == 0 )
425424 {
426- elog (WARNING , "Process %d is using backup %s, and is still running" ,
427- encoded_pid , backup_id );
425+ elog (WARNING , "Process %lld is using backup %s, and is still running" ,
426+ ( long long ) encoded_pid , backup_id );
428427
429428 elog (WARNING , "Waiting %u seconds on exclusive lock for backup %s" ,
430429 ntries , backup_id );
@@ -438,8 +437,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
438437 else
439438 {
440439 if (errno == ESRCH )
441- elog (WARNING , "Process %d which used backup %s no longer exists" ,
442- encoded_pid , backup_id );
440+ elog (WARNING , "Process %lld which used backup %s no longer exists" ,
441+ ( long long ) encoded_pid , backup_id );
443442 else
444443 elog (ERROR , "Failed to send signal 0 to a process %d: %s" ,
445444 encoded_pid , strerror (errno ));
@@ -468,7 +467,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
468467 /*
469468 * Successfully created the file, now fill it.
470469 */
471- snprintf (buffer , sizeof (buffer ), "%d \n" , my_pid );
470+ snprintf (buffer , sizeof (buffer ), "%lld \n" , ( long long ) my_pid );
472471
473472 errno = 0 ;
474473 if (fio_write (fd , buffer , strlen (buffer )) != strlen (buffer ))
@@ -575,8 +574,8 @@ wait_shared_owners(pgBackup *backup)
575574 /* complain from time to time */
576575 if ((ntries % LOG_FREQ ) == 0 )
577576 {
578- elog (WARNING , "Process %d is using backup %s in shared mode, and is still running" ,
579- encoded_pid , base36enc (backup -> start_time ));
577+ elog (WARNING , "Process %lld is using backup %s in shared mode, and is still running" ,
578+ ( long long ) encoded_pid , base36enc (backup -> start_time ));
580579
581580 elog (WARNING , "Waiting %u seconds on lock for backup %s" , ntries ,
582581 base36enc (backup -> start_time ));
@@ -588,8 +587,8 @@ wait_shared_owners(pgBackup *backup)
588587 continue ;
589588 }
590589 else if (errno != ESRCH )
591- elog (ERROR , "Failed to send signal 0 to a process %d : %s" ,
592- encoded_pid , strerror (errno ));
590+ elog (ERROR , "Failed to send signal 0 to a process %lld : %s" ,
591+ ( long long ) encoded_pid , strerror (errno ));
593592
594593 /* locker is dead */
595594 break ;
@@ -606,8 +605,8 @@ wait_shared_owners(pgBackup *backup)
606605 /* some shared owners are still alive */
607606 if (ntries <= 0 )
608607 {
609- elog (WARNING , "Cannot to lock backup %s in exclusive mode, because process %u owns shared lock" ,
610- base36enc (backup -> start_time ), encoded_pid );
608+ elog (WARNING , "Cannot to lock backup %s in exclusive mode, because process %llu owns shared lock" ,
609+ base36enc (backup -> start_time ), ( long long ) encoded_pid );
611610 return 1 ;
612611 }
613612
@@ -662,11 +661,11 @@ grab_shared_lock_file(pgBackup *backup)
662661 * Somebody is still using this backup in shared mode,
663662 * copy this pid into a new file.
664663 */
665- buffer_len += snprintf (buffer + buffer_len , 4096 , "%u \n" , encoded_pid );
664+ buffer_len += snprintf (buffer + buffer_len , 4096 , "%llu \n" , ( long long ) encoded_pid );
666665 }
667666 else if (errno != ESRCH )
668- elog (ERROR , "Failed to send signal 0 to a process %d : %s" ,
669- encoded_pid , strerror (errno ));
667+ elog (ERROR , "Failed to send signal 0 to a process %lld : %s" ,
668+ ( long long ) encoded_pid , strerror (errno ));
670669 }
671670
672671 if (fp_in )
@@ -686,7 +685,7 @@ grab_shared_lock_file(pgBackup *backup)
686685 }
687686
688687 /* add my own pid */
689- buffer_len += snprintf (buffer + buffer_len , sizeof (buffer ), "%u \n" , my_pid );
688+ buffer_len += snprintf (buffer + buffer_len , sizeof (buffer ), "%llu \n" , ( long long ) my_pid );
690689
691690 /* write out the collected PIDs to temp lock file */
692691 fwrite (buffer , 1 , buffer_len , fp_out );
@@ -784,11 +783,11 @@ release_shared_lock_file(const char *backup_dir)
784783 * Somebody is still using this backup in shared mode,
785784 * copy this pid into a new file.
786785 */
787- buffer_len += snprintf (buffer + buffer_len , 4096 , "%u \n" , encoded_pid );
786+ buffer_len += snprintf (buffer + buffer_len , 4096 , "%llu \n" , ( long long ) encoded_pid );
788787 }
789788 else if (errno != ESRCH )
790- elog (ERROR , "Failed to send signal 0 to a process %d : %s" ,
791- encoded_pid , strerror (errno ));
789+ elog (ERROR , "Failed to send signal 0 to a process %lld : %s" ,
790+ ( long long ) encoded_pid , strerror (errno ));
792791 }
793792
794793 if (ferror (fp_in ))
0 commit comments