nicolas / debian.moreutils (public) (License: GPL-2, GPL-2+, Expat, BSD-2-Clause, Public Domain) (since 2018-09-25) (hash sha1)
Debian packaging of joeyh's moreutils
List of commits:
Subject Hash Author Date (UTC)
parallel: Implement -l (maxload) and -i (replace {}) e608a0284a84bb37a5a621eae72b0a456ec5484b Tollef Fog Heen 2009-06-30 02:49:07
parallel: Fix typo in usage string 397defef1f5994344d261cda1cfffb1e21d935cc Tollef Fog Heen 2009-06-30 02:28:00
Return non-zero if something goes wrong cde80342f40f2393f5a76974adf595d5aeb2ec52 Tollef Fog Heen 2009-06-30 02:26:16
Compile parallel by default b55a8e3a90e876fe1b80c886e63bb5d9fe0e022a Tollef Fog Heen 2009-06-30 02:25:55
Add initial writeup of parallel tool 0f012c74fcfaea8d661a729fd5cc2ad4f3563115 Tollef Fog Heen 2009-06-30 02:19:07
releasing version 0.35 b729d870341ae06f9a5a945717eb61c1d60a3af5 Joey Hess 2009-05-05 19:19:37
remove unnecessary quotes b08aeb0570bfd28f29a7708ab65f0f09f89e3883 Joey Hess 2009-05-05 19:09:40
isutf8: Reject UTF-8-encoded UTF-16 surrogates. Closes: #525301 (Thanks, Jakub Wilk and liw) a250ae89f37849be1caf204a07d2e4e563503390 Joey Hess 2009-05-05 19:06:34
ifdata: Don't assume that all interface names are 6 characters or less, for instance "wmaster0" is longer. Increase the limit to 20 characters. Closes: #526654 (Thanks, Alan Pope) 0aa82b9e712f62170d7f433b9fb181cdc6a60a92 Joey Hess 2009-05-03 00:41:06
releasing version 0.34 3e03d4c45318bb0978e65850ec7f56bbb210d4f1 Joey Hess 2008-12-11 20:12:53
vipe: Avoid dying on empty input. Thanks, Anders Kaseorg Closes: #508491 931de139ed875e6c593d0bdb692fccf181da46bb Joey Hess 2008-12-11 20:11:19
releasing version 0.33 6f2bc6bff8786f96265b170249b4cd4bc3e99247 Joey Hess 2008-10-31 21:03:08
Fix zrun breakage introduced last version. Closes: #504129 0815e5fa8d11ea9bd235d536e02e108ab1cecb43 Joey Hess 2008-10-31 21:01:02
changelog 61290da144f6138269f3050388ed18b17038d580 Joey Hess 2008-10-28 02:41:30
Support installing moreutils into prefixes other than /usr 220a73731d4506912e8ec2ecca2e33abdf4e01fe Evan Broder 2008-10-28 01:58:48
Fix pod error in vidir(1). 1e73fbbb25bc43999320b2c9c5679ab0c8f3b528 Joey Hess 2008-10-27 03:51:00
zrun: Can be linked to zsomeprog to run the equivilant of zrun someprog. 9c2bf6a2f6885d4f6373b5a682d10c40c84b4e66 Joey Hess 2008-09-27 22:05:33
typo 39bc764104ad5268b9312a7ff49ff10d7907dd6b Joey Hess 2008-07-09 17:06:26
releasing version 0.31 8b407b19baf9819f186142653b77ed63977e244e Joey Hess 2008-06-29 03:23:15
ts: Support displaying fractional seconds via a "%.S" conversion specification. Closes: #482789 729a9ec3a9be3b611a180c08daf9191c20506a09 Joey Hess 2008-05-28 18:32:48
Commit e608a0284a84bb37a5a621eae72b0a456ec5484b - parallel: Implement -l (maxload) and -i (replace {})
Add support for only starting jobs when the load average is low
enough, this is done with -l and acts similarly to how make does it.

In order to construct more complex commands, add -i which will make
parallel replace {} with the argument at an arbitrary place in the
command line.
Author: Tollef Fog Heen
Author date (UTC): 2009-06-30 02:49
Committer name: Tollef Fog Heen
Committer date (UTC): 2009-06-30 02:49
Parent(s): 397defef1f5994344d261cda1cfffb1e21d935cc
Signing key:
Tree: 4ab7f814c0bbb0fedb9354b3f153c2c3a16ac178
File Lines added Lines deleted
parallel.c 39 11
File parallel.c changed (mode: 100644) (index 2333a3d..438bc93)
... ... void usage()
38 38 exit(1); exit(1);
39 39 } }
40 40
41 void exec_child(char **command, char *argument)
41 void exec_child(char **command, char *argument, int replace_cb)
42 42 { {
43 43 char **argv; char **argv;
44 44 int argc = 0; int argc = 0;
 
... ... void exec_child(char **command, char *argument)
47 47 while (command[argc] != 0) { while (command[argc] != 0) {
48 48 argc++; argc++;
49 49 } }
50 argc++;
50 if (replace_cb == 0)
51 argc++;
51 52 argv = calloc(sizeof(char*), argc+1); argv = calloc(sizeof(char*), argc+1);
52 53 for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
53 54 argv[i] = command[i]; argv[i] = command[i];
55 if (replace_cb && (strcmp(argv[i], "{}") == 0))
56 argv[i] = argument;
54 57 } }
55 argv[i-1] = argument;
58 if (replace_cb == 0)
59 argv[i-1] = argument;
56 60 if (fork() == 0) { if (fork() == 0) {
57 61 /* Child */ /* Child */
58 62 execvp(argv[0], argv); execvp(argv[0], argv);
 
... ... void exec_child(char **command, char *argument)
61 65 return; return;
62 66 } }
63 67
64 int wait_for_child(void)
68 int wait_for_child(int options)
65 69 { {
66 70 id_t id_ignored = 0; id_t id_ignored = 0;
67 71 siginfo_t infop; siginfo_t infop;
68 waitid(P_ALL, id_ignored, &infop, WEXITED);
72
73 infop.si_pid = 0;
74 waitid(P_ALL, id_ignored, &infop, WEXITED | options);
75 if (infop.si_pid == 0)
76 return -1; /* Nothing to wait for */
69 77 if (infop.si_code == CLD_EXITED) if (infop.si_code == CLD_EXITED)
70 78 return infop.si_status; return infop.si_status;
71 79 return 1; return 1;
 
... ... int main(int argc, char **argv)
82 90 int argidx = 0; int argidx = 0;
83 91 int cidx = 0; int cidx = 0;
84 92 int returncode = 0; int returncode = 0;
93 int replace_cb = 0;
85 94
86 while ((opt = getopt(argc, argv, "+hj:l:")) != -1) {
95 while ((opt = getopt(argc, argv, "+hij:l:")) != -1) {
87 96 switch (opt) { switch (opt) {
88 97 case 'h': case 'h':
89 98 usage(); usage();
90 99 break; break;
100 case 'i':
101 replace_cb = 1;
102 break;
91 103 case 'j': case 'j':
92 104 maxjobs = atoi(optarg); maxjobs = atoi(optarg);
93 105 break; break;
 
... ... int main(int argc, char **argv)
100 112 } }
101 113 } }
102 114
103 if (maxjobs < 0) {
115 if (maxjobs < 0 && maxload < 0) {
104 116 usage(); usage();
105 117 } }
106 118
 
... ... int main(int argc, char **argv)
130 142 } }
131 143
132 144 while (arguments[argidx] != 0) { while (arguments[argidx] != 0) {
133 if (maxjobs > 0 && curjobs < maxjobs) {
134 exec_child(command, arguments[argidx]);
145 double load;
146
147 getloadavg(&load, 1);
148
149 if ((maxjobs > 0 && curjobs < maxjobs) ||
150 (maxload > 0 && load < maxload)) {
151 exec_child(command, arguments[argidx], replace_cb);
135 152 argidx++; argidx++;
136 153 curjobs++; curjobs++;
137 154 } }
138 155
139 156 if (maxjobs > 0 && curjobs == maxjobs) { if (maxjobs > 0 && curjobs == maxjobs) {
140 returncode |= wait_for_child();
157 returncode |= wait_for_child(0);
141 158 curjobs--; curjobs--;
142 159 } }
160
161 if (maxload > 0 && load > maxload) {
162 int r;
163 sleep(1); /* XXX We should have a better
164 * heurestic than this */
165 r = wait_for_child(WNOHANG);
166 if (r > 0) {
167 returncode |= r;
168 curjobs--;
169 }
170 }
143 171 } }
144 172 while (curjobs > 0) { while (curjobs > 0) {
145 returncode |= wait_for_child();
173 returncode |= wait_for_child(0);
146 174 curjobs--; curjobs--;
147 175 } }
148 176
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/nicolas/debian.moreutils

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/nicolas/debian.moreutils

Clone this repository using git:
git clone git://git.rocketgit.com/user/nicolas/debian.moreutils

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main