__progname shouldn't be declared in the function. Move it to file scope.