diff --git a/syncoid b/syncoid index 29b7319..f842d4d 100755 --- a/syncoid +++ b/syncoid @@ -773,7 +773,8 @@ sub syncdataset { }; $exit == 0 or do { - if (!$resume && $stdout =~ /\Qcontains partially-complete state\E/) { + # FreeBSD reports "dataset is busy" instead of "contains partially-complete state" + if (!$resume && ($stdout =~ /\Qcontains partially-complete state\E/ || $stdout =~ /\Qdataset is busy\E/)) { if (!$quiet) { print "WARN: resetting partially receive state\n"; } resetreceivestate($targethost,$targetfs,$targetisroot); system("$synccmd") == 0 or do { diff --git a/tests/syncoid/5_reset_resume_state/run.sh b/tests/syncoid/5_reset_resume_state/run.sh index 6e1b22b..6e71002 100755 --- a/tests/syncoid/5_reset_resume_state/run.sh +++ b/tests/syncoid/5_reset_resume_state/run.sh @@ -23,7 +23,7 @@ function cleanUp { # export pool in any case trap cleanUp EXIT -zfs create "${POOL_NAME}"/src -o mountpoint="${MOUNT_TARGET}" +zfs create -o mountpoint="${MOUNT_TARGET}" "${POOL_NAME}"/src ../../../syncoid --debug --compress=none "${POOL_NAME}"/src "${POOL_NAME}"/dst dd if=/dev/urandom of="${MOUNT_TARGET}"/big_file bs=1M count=200 @@ -31,19 +31,16 @@ dd if=/dev/urandom of="${MOUNT_TARGET}"/big_file bs=1M count=200 ../../../syncoid --debug --compress=none --source-bwlimit=2m "${POOL_NAME}"/src "${POOL_NAME}"/dst & syncoid_pid=$! sleep 5 -list_descendants () -{ - local children=$(ps -o pid= --ppid "$1") - - for pid in $children - do - list_descendants "$pid" - done - - echo "$children" +function getcpid() { + cpids=$(pgrep -P "$1"|xargs) + for cpid in $cpids; + do + echo "$cpid" + getcpid "$cpid" + done } -kill $(list_descendants $$) || true +kill $(getcpid $$) || true wait sleep 1 diff --git a/tests/syncoid/6_reset_resume_state2/run.sh b/tests/syncoid/6_reset_resume_state2/run.sh index e227223..1afc921 100755 --- a/tests/syncoid/6_reset_resume_state2/run.sh +++ b/tests/syncoid/6_reset_resume_state2/run.sh @@ -23,7 +23,7 @@ function cleanUp { # export pool in any case trap cleanUp EXIT -zfs create "${POOL_NAME}"/src -o mountpoint="${MOUNT_TARGET}" +zfs create -o mountpoint="${MOUNT_TARGET}" "${POOL_NAME}"/src ../../../syncoid --debug --compress=none "${POOL_NAME}"/src "${POOL_NAME}"/dst dd if=/dev/urandom of="${MOUNT_TARGET}"/big_file bs=1M count=200 @@ -32,19 +32,16 @@ zfs snapshot "${POOL_NAME}"/src@big ../../../syncoid --debug --no-sync-snap --compress=none --source-bwlimit=2m "${POOL_NAME}"/src "${POOL_NAME}"/dst & syncoid_pid=$! sleep 5 -list_descendants () -{ - local children=$(ps -o pid= --ppid "$1") - - for pid in $children - do - list_descendants "$pid" - done - - echo "$children" +function getcpid() { + cpids=$(pgrep -P "$1"|xargs) + for cpid in $cpids; + do + echo "$cpid" + getcpid "$cpid" + done } -kill $(list_descendants $$) || true +kill $(getcpid $$) || true wait sleep 1