You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
725 B

  1. #include <stdio.h>
  2. #include "util.h"
  3. /* ARGSUSED */
  4. static int
  5. saveit(prog, file2)
  6. char *prog, *file2;
  7. {
  8. char *file1;
  9. /* get current executable name by searching the path ... */
  10. file1 = util_path_search(prog);
  11. if (file1 == 0) {
  12. (void) fprintf(stderr, "cannot locate current executable\n");
  13. return 1;
  14. }
  15. /* users name for the new executable -- perform tilde-expansion */
  16. if (! util_save_image(file1, file2)) {
  17. (void) fprintf(stderr, "error occured during save ...\n");
  18. return 1;
  19. }
  20. FREE(file1);
  21. return 0;
  22. }
  23. int restart;
  24. main(argc, argv)
  25. char **argv;
  26. {
  27. if (restart) {
  28. (void) printf("restarted ...\n");
  29. exit(0);
  30. }
  31. restart = 1;
  32. exit(saveit(argv[0], "foobar"));
  33. }