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)
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
pee.1: Document difference with tee in stdout. 478d7c32b226dcdd364a7a669115a0e093545d68 Joey Hess 2008-05-28 17:42:18
releasing version 0.30 8a49d33f795107df284a8ca1a1ad8524c3e88865 Joey Hess 2008-05-14 23:42:14
ifne: If no command is specified, print usage information. 99e7bc2550ca8fc57af19410e28958e46a2d6f15 Joey Hess 2008-05-12 20:04:36
Added -n option to ifne. 4425bfd45edfc4d2be18ce6d2a2eeb7ab80f7a6c Vicho 2008-05-01 10:17:45
Commit 0f012c74fcfaea8d661a729fd5cc2ad4f3563115 - Add initial writeup of parallel tool
Author: Tollef Fog Heen
Author date (UTC): 2009-06-30 02:19
Committer name: Tollef Fog Heen
Committer date (UTC): 2009-06-30 02:19
Parent(s): b729d870341ae06f9a5a945717eb61c1d60a3af5
Signer:
Signing key:
Signing status: N
Tree: f0c524e7e362318d126b9a47743168196289d69b
File Lines added Lines deleted
parallel.c 144 0
File parallel.c added (mode: 100644) (index 0000000..09588d6)
1
2 /*
3 * parallel.c - run commands in parallel until you run out of commands
4 *
5 * Copyright © 2008 Tollef Fog Heen <tfheen@err.no>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 *
21 */
22
23 #define _GNU_SOURCE
24 #include <unistd.h>
25 #include <string.h>
26 #include <stdio.h>
27 #include <sys/time.h>
28 #include <time.h>
29 #include <stdlib.h>
30 #include <sys/select.h>
31 #include <sys/types.h>
32 #include <sys/wait.h>
33
34 void usage()
35 {
36 printf("parallel [OPTIONS] command -- arguments: for each argument,"
37 "run command with argument\n");
38 exit(1);
39 }
40
41 void exec_child(char **command, char *argument)
42 {
43 char **argv;
44 int argc = 0;
45 int i;
46
47 while (command[argc] != 0) {
48 argc++;
49 }
50 argc++;
51 argv = calloc(sizeof(char*), argc+1);
52 for (i = 0; i < argc; i++) {
53 argv[i] = command[i];
54 }
55 argv[i-1] = argument;
56 if (fork() == 0) {
57 /* Child */
58 execvp(argv[0], argv);
59 exit(1);
60 }
61 return;
62 }
63
64 int main(int argc, char **argv)
65 {
66 int maxjobs = -1;
67 int curjobs = 0;
68 int maxload = -1;
69 int opt;
70 char **command = calloc(sizeof(char*), argc);
71 char **arguments;
72 int argidx = 0;
73 int cidx = 0;
74
75 while ((opt = getopt(argc, argv, "+hj:l:")) != -1) {
76 switch (opt) {
77 case 'h':
78 usage();
79 break;
80 case 'j':
81 maxjobs = atoi(optarg);
82 break;
83 case 'l':
84 maxload = atoi(optarg);
85 break;
86 default: /* ’?’ */
87 usage();
88 break;
89 }
90 }
91
92 if (maxjobs < 0) {
93 usage();
94 }
95
96 while (optind < argc) {
97 if (strcmp(argv[optind], "--") == 0) {
98 int i;
99 size_t mem = (sizeof (char*)) * (argc - optind);
100
101 arguments = malloc(mem);
102 if (! arguments) {
103 exit(1);
104 }
105 memset(arguments, 0, mem);
106 optind++; /* Skip the -- separator, skip after
107 * malloc so we have a trailing
108 * null */
109
110 for (i = 0; i < argc - optind; i++) {
111 arguments[i] = strdup(argv[optind + i]);
112 }
113 optind += i;
114 } else {
115 command[cidx] = strdup(argv[optind]);
116 cidx++;
117 }
118 optind++;
119 }
120
121 while (arguments[argidx] != 0) {
122 if (maxjobs > 0 && curjobs < maxjobs) {
123 exec_child(command, arguments[argidx]);
124 argidx++;
125 curjobs++;
126 }
127
128 if (maxjobs > 0 && curjobs == maxjobs) {
129 id_t id_ignored;
130 siginfo_t infop_ignored;
131 waitid(P_ALL, id_ignored, &infop_ignored, WEXITED);
132 curjobs--;
133 }
134 }
135 while (curjobs > 0) {
136 id_t id_ignored;
137 siginfo_t infop_ignored;
138 waitid(P_ALL, id_ignored, &infop_ignored, WEXITED);
139 curjobs--;
140 }
141
142 return 0;
143 }
144
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