iothrottle: Clean up /tmp if iothrottle is killed.
This commit is contained in:
parent
9a39d50440
commit
1d41f696cc
25
iothrottle/Makefile
Normal file
25
iothrottle/Makefile
Normal file
|
@ -0,0 +1,25 @@
|
|||
all: iothrottle
|
||||
true
|
||||
|
||||
iothrottle: iothrottle.hex iothrottle.in
|
||||
perl -pe 's/hex=.*/"hex=".`cat iothrottle.hex`/e' iothrottle.in > iothrottle
|
||||
chmod +x iothrottle
|
||||
|
||||
iothrottle.so: iothrottle.c
|
||||
gcc -O2 -shared -fPIC -o iothrottle.so iothrottle.c -ldl
|
||||
strip iothrottle.so
|
||||
|
||||
iothrottle.hex: iothrottle.so
|
||||
hexdump -ve '1/1 "%.2x"' iothrottle.so > iothrottle.hex
|
||||
LC_ALL=C awk '{for (i=1; i<=length($$0); i+=2) printf "%c", strtonum("0x" substr($$0, i, 2))}' iothrottle.hex > iothrottle.bin
|
||||
md5sum iothrottle.so iothrottle.bin
|
||||
|
||||
test: iothrottle
|
||||
seq 10000000 | cat | pv > big
|
||||
./iothrottle cat big | pv > /dev/null
|
||||
./iothrottle -i 20M cat big | pv > /dev/null
|
||||
./iothrottle -o 20000K cat big | pv > /dev/null
|
||||
rm big
|
||||
|
||||
clean:
|
||||
rm -f iothrottle.so iothrottle.hex iothrottle.bin iothrottle iothrottle.1 iothrottle~
|
|
@ -47,14 +47,26 @@ Copy mydir at 1MB/s:
|
|||
iothrottle -i 1M cp -a mydir/ /other/filesystem/
|
||||
|
||||
|
||||
=head1 BUGS
|
||||
=head1 LIMITATIONS
|
||||
|
||||
B<iothrottle> intercepts calls to B<read>(2) and B<write>(2). If too
|
||||
much is read/written it inserts a pause for each call. This means the
|
||||
speed can go over the limit for a single call. Thus if the limit is
|
||||
400 bytes/sec, but the call moves 4096 bytes, there will be a pause of
|
||||
10 secs.
|
||||
|
||||
Not all program use B<read>(2) and B<write>(2) for I/O.
|
||||
|
||||
These all use other methods: cp (to same filesystem), seq
|
||||
|
||||
File a bug report when you find other programs:
|
||||
https://git.data.coop/tange/tangetools/issues
|
||||
Statically linked programs will also not work.
|
||||
|
||||
File a bug report when you find other programs.
|
||||
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
File bugs at: https://git.data.coop/tange/tangetools/issues
|
||||
|
||||
|
||||
=head1 ENVIRONMENT VARIABLES
|
||||
|
@ -106,14 +118,18 @@ B<ionice>, B<bwlimit>
|
|||
|
||||
|
||||
_hex() {
|
||||
# hex encoded iothrottle.so
|
||||
local hex=dummy
|
||||
echo $hex
|
||||
}
|
||||
|
||||
_hex_to_bin() {
|
||||
LC_ALL=C awk '{for (i=1; i<=length($0); i+=2) printf "%c", strtonum("0x" substr($0, i, 2))}'
|
||||
}
|
||||
|
||||
_iothrottle.so() {
|
||||
local iothrottleso=$(mktemp)
|
||||
_hex |
|
||||
LC_ALL=C awk '{for (i=1; i<=length($0); i+=2) printf "%c", strtonum("0x" substr($0, i, 2))}' > "$iothrottleso"
|
||||
local iothrottleso=$(mktemp -t iotrottle.XXXXX)
|
||||
_hex | _hex_to_bin > "$iothrottleso"
|
||||
echo "$iothrottleso"
|
||||
}
|
||||
|
||||
|
@ -169,6 +185,12 @@ if [ IOTHROTTLE_DEBUG = 1 ] ; then
|
|||
echo LD_PRELOAD=$_so
|
||||
LD_PRELOAD=$_so "$@"
|
||||
else
|
||||
cleanup() {
|
||||
# if parent is dead: remove tmpfile
|
||||
ppid=$1
|
||||
while kill -0 $ppid 2>/dev/null; do sleep 1; done
|
||||
rm $_so
|
||||
}
|
||||
cleanup $$ &
|
||||
LD_PRELOAD=$_so "$@"
|
||||
rm $_so
|
||||
fi
|
||||
|
|
|
@ -10,7 +10,7 @@ INSTALLATION (create directories if they donot exist):
|
|||
- The extension can then be found in the menu:
|
||||
View > Split video in two
|
||||
- It requires 'splitvideo' from
|
||||
https://gitlab.com/ole.tange/tangetools/tree/master/splitvideo
|
||||
https://git.data.coop/tange/tangetools/src/branch/master/splitvideo/splitvideo
|
||||
to be in $PATH
|
||||
]]--
|
||||
|
||||
|
@ -24,7 +24,7 @@ function descriptor()
|
|||
description = "<h1>Split Video</h1>"
|
||||
.. "When you're playing a file, use Split Video to "
|
||||
.. "split the file into two files at the current time stamp. " ;
|
||||
url = "https://gitlab.com/ole.tange/tangetools/tree/master/splitvideo"
|
||||
url = "https://git.data.coop/tange/tangetools/src/branch/master/splitvideo"
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ B<splitvideo> can be used on the commandline:
|
|||
splitvideo 3600 myvideo.mp4
|
||||
|
||||
It can also be called from VLC by installing B<splitvideo.lua> from
|
||||
https://gitlab.com/ole.tange/tangetools/tree/master/splitvideo in
|
||||
https://git.data.coop/tange/tangetools/src/branch/master/splitvideo in
|
||||
B<~/.local/share/vlc/lua/extensions/>
|
||||
|
||||
|
||||
|
|
3
vid/vid
3
vid/vid
|
@ -162,7 +162,8 @@ cat_list() {
|
|||
# cat "$vidlist" | grep matching this dir + remove dirs
|
||||
# echo "$vidlist" "$full_path_thisdir" "$full_path_vidlist_dir" = "$subdir" >&2
|
||||
grep -v '/.waste/' "$vidlist" |
|
||||
perl -ne 's|^(\./)?\Q'"$subdir"'\E|| and print'
|
||||
perl -ne 's|^(\./)?\Q'"$subdir"'\E|| and print' |
|
||||
sort -u
|
||||
}
|
||||
|
||||
stdin() {
|
||||
|
|
Loading…
Reference in a new issue