mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
shellsync: cleanup package (#8812)
Co-authored-by: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com>
This commit is contained in:
parent
4d99aba7a6
commit
308842ef19
@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/package.mk
|
|||||||
|
|
||||||
define Package/shellsync
|
define Package/shellsync
|
||||||
CATEGORY:=Utilities
|
CATEGORY:=Utilities
|
||||||
TITLE:=shellsync
|
TITLE:=Sync shell scripts
|
||||||
DEPENDS:=+libpthread +kmod-macvlan
|
DEPENDS:=+libpthread +kmod-macvlan
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -18,7 +18,8 @@ define Build/Prepare
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/shellsync/description
|
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
|
endef
|
||||||
|
|
||||||
define Build/Compile
|
define Build/Compile
|
||||||
@ -30,5 +31,4 @@ define Package/shellsync/install
|
|||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/shellsync $(1)/usr/bin
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/shellsync $(1)/usr/bin
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,shellsync))
|
$(eval $(call BuildPackage,shellsync))
|
||||||
|
@ -4,20 +4,23 @@
|
|||||||
> Mail: gch981213@gmail.com
|
> Mail: gch981213@gmail.com
|
||||||
> Created Time: 2014年11月06日 星期四 19时15分30秒
|
> Created Time: 2014年11月06日 星期四 19时15分30秒
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#include<stdio.h>
|
#include <stdio.h>
|
||||||
#include<semaphore.h>
|
#include <semaphore.h>
|
||||||
#include<fcntl.h>
|
#include <fcntl.h>
|
||||||
#include<stdlib.h>
|
#include <stdlib.h>
|
||||||
#include<time.h>
|
#include <time.h>
|
||||||
#include<errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define SEM_BLOCK_NAME "SYNCSHELL_block"
|
#define SEM_BLOCK_NAME "SYNCSHELL_block"
|
||||||
#define SEM_COUNT_NAME "SYNCSHELL_count"
|
#define SEM_COUNT_NAME "SYNCSHELL_count"
|
||||||
|
|
||||||
int wait_timeout;
|
int wait_timeout;
|
||||||
|
|
||||||
int sync_wait(int nproc)
|
int sync_wait(int nproc)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int value;
|
int value;
|
||||||
sem_t *block;
|
sem_t *block;
|
||||||
sem_t *count;
|
sem_t *count;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
@ -32,7 +35,6 @@ int sync_wait(int nproc)
|
|||||||
}
|
}
|
||||||
ts.tv_sec += wait_timeout;
|
ts.tv_sec += wait_timeout;
|
||||||
|
|
||||||
|
|
||||||
flags = O_RDWR | O_CREAT;
|
flags = O_RDWR | O_CREAT;
|
||||||
block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0);
|
block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0);
|
||||||
count = sem_open(SEM_COUNT_NAME, flags, 0644, 0);
|
count = sem_open(SEM_COUNT_NAME, flags, 0644, 0);
|
||||||
@ -50,6 +52,7 @@ int sync_wait(int nproc)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("%d processes have arrived, waiting for the left %d\n", value, nproc-value);
|
printf("%d processes have arrived, waiting for the left %d\n", value, nproc-value);
|
||||||
|
|
||||||
if (value >= nproc) {
|
if (value >= nproc) {
|
||||||
while (nproc-1 > 0) {
|
while (nproc-1 > 0) {
|
||||||
if (sem_post(block) < 0) {
|
if (sem_post(block) < 0) {
|
||||||
@ -67,7 +70,6 @@ int sync_wait(int nproc)
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_close(count);
|
sem_close(count);
|
||||||
|
Loading…
Reference in New Issue
Block a user