shellsync: cleanup package (#8812)

Co-authored-by: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com>
This commit is contained in:
Beginner 2022-02-02 12:01:01 +08:00 committed by GitHub
parent 4d99aba7a6
commit 308842ef19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View File

@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/shellsync
CATEGORY:=Utilities
TITLE:=shellsync
TITLE:=Sync shell scripts
DEPENDS:=+libpthread +kmod-macvlan
endef
@ -18,7 +18,8 @@ define Build/Prepare
endef
define Package/shellsync/description
A tool to sync different shell scripts.Based on syncppp patch by morfast.
A tool to sync different shell scripts.
Based on syncppp patch by morfast.
endef
define Build/Compile
@ -30,5 +31,4 @@ define Package/shellsync/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/shellsync $(1)/usr/bin
endef
$(eval $(call BuildPackage,shellsync))

View File

@ -4,15 +4,18 @@
> Mail: gch981213@gmail.com
> Created Time: 20141106 191530
************************************************************************/
#include<stdio.h>
#include<semaphore.h>
#include<fcntl.h>
#include<stdlib.h>
#include<time.h>
#include<errno.h>
#include <stdio.h>
#include <semaphore.h>
#include <fcntl.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#define SEM_BLOCK_NAME "SYNCSHELL_block"
#define SEM_COUNT_NAME "SYNCSHELL_count"
int wait_timeout;
int sync_wait(int nproc)
{
int flags;
@ -32,7 +35,6 @@ int sync_wait(int nproc)
}
ts.tv_sec += wait_timeout;
flags = O_RDWR | O_CREAT;
block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0);
count = sem_open(SEM_COUNT_NAME, flags, 0644, 0);
@ -50,6 +52,7 @@ int sync_wait(int nproc)
return -1;
}
printf("%d processes have arrived, waiting for the left %d\n", value, nproc-value);
if (value >= nproc) {
while (nproc-1 > 0) {
if (sem_post(block) < 0) {
@ -67,7 +70,6 @@ int sync_wait(int nproc)
}
return -1;
}
}
sem_close(count);