#!/usr/bin/perl

use warnings;
use strict;
use File::Which;

my @run = ("git-shell", @ARGV);
if (my $ipc = $ENV{IPC} and
    my $tracer = which("iotrace") || which("strace")) {
    # Using strace -f imposes the danger of split brain trace logs.
    exec $tracer => -v => -s => 32768 => -tt => -e => "execve,clone,openat,close,read,write" => -o => "$ipc/log.trace" => @run;
    # If strace or iotrace fail to launch, then continue on to @run anyways
}
else {
    warn localtime().": WARNING: git-server: Missing iotrace and strace\n";
}
exec @run or die "exec: Failed to spawn! $!\n";
