[net.lang.c] self-abusing C programs

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (08/29/84)

There is a whole family of self-reproducing programs that extends
quite easily to bistable, tristable, etc. groupings as well as to
self-reversing programs and any other specified transformation:

/* this file is source.c */
main(){system("cat source.c");}

This reduces most such questions to triviality.

jcz@ncsu.UUCP (John Carl Zeigler) (08/31/84)

Re:    main(){system("cat foo.c");}

I beleive there is an implicit assumption that programs that
simply print out their source files do not qualify as
"self reproducing" because they are so trivial.  If we alow this,
then cat can produce any arbitrary program whose source is already
on the system.  Not very exciting.

--jcz
North Carolina State University

jack@rlgvax.UUCP (09/04/84)

> Re:    main(){system("cat foo.c");}
> 
> I beleive there is an implicit assumption that programs that
> simply print out their source files do not qualify as
> "self reproducing" because they are so trivial.  If we alow this,
> then cat can produce any arbitrary program whose source is already
> on the system.  Not very exciting.
> 
> --jcz
> North Carolina State University

To make writing self-replicating C programs fun, I'd say
the reasonable restriction is that they are forbidden to
make any system call except 'write'.

I have one that satisfies the further restriction that
it makes no call on any library routine except 'write'.