--- /dev/null
+CC=/usr/bin/gcc
+CF=-g -Wall
+
+all: runcwd runcwdi test
+
+runcwd: runcwd.c
+ $(CC) $(CF) -o runcwd runcwd.c
+
+runcwdi: runcwdi.c
+ $(CC) $(CF) -o runcwdi runcwdi.c
+
+test: test.c
+ $(CC) $(CF) -o test test.c
--- /dev/null
+//Niezła wymota
+//This generic wrapper allows to run a program with specified CWD. First argument is the CWD, second is the program to run, rest are the parameters passed to that program
+
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+ int r;
+
+ if (argc<2) {
+ fprintf(stderr,"%s\n","CWD missing.");
+ return 1;
+ }
+ else if (argc <3) {
+ fprintf(stderr,"%s\n","Command missing.");
+ return 1;
+ }
+
+ if (chdir(argv[1]))
+ fprintf(stderr,"Chdir to %s failed.\n",argv[1]);
+
+ r=execve(argv[2],argv+2,envp);
+
+ fprintf(stderr,"Failed to run %s.\n",argv[2]);
+ return r;
+}
--- /dev/null
+//Niezła wymota
+//This generic wrapper allows to run a program with specified CWD. First argument is the CWD (must end with "/", anything after it is ignored), second is the program to run, rest are the parameters passed to that program
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+ int r;
+
+ if (argc<2) {
+ fprintf(stderr,"%s\n","CWD missing.");
+ return 1;
+ }
+ else if (argc <3) {
+ fprintf(stderr,"%s\n","Command missing.");
+ return 1;
+ }
+
+ for (r=strlen(argv[1])-1; r>=0; --r)
+ {
+ if (argv[1][r] == '/')
+ break;
+ argv[1][r]=0;
+ }
+
+ if (chdir(argv[1]))
+ fprintf(stderr,"Chdir to %s failed.\n",argv[1]);
+
+ r=execve(argv[2],argv+2,envp);
+
+ fprintf(stderr,"Failed to run %s.\n",argv[2]);
+ return r;
+}
--- /dev/null
+//Niezła wymota
+//This generic wrapper allows to run a program with specified CWD. First argument is the CWD (must end with "/", anything after it is ignored), second is the program to run, rest are the parameters passed to that program
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+ int r;
+ FILE* file;
+
+ if (argc<2) {
+ fprintf(stderr,"%s\n","CWD missing.");
+ return 1;
+ }
+ else if (argc <3) {
+ fprintf(stderr,"%s\n","Command missing.");
+ return 1;
+ }
+
+ for (r=strlen(argv[1])-1; r>=0; --r)
+ {
+ if (argv[1][r] == '/')
+ break;
+ argv[1][r]=0;
+ }
+
+ if (chdir(argv[1]))
+ fprintf(stderr,"Chdir to %s failed.\n",argv[1]);
+
+ file=fopen("/home/b/pro/runcwd/cwda.txt","a");
+ if (file != NULL) {
+ for (r=0; r<argc; ++r)
+ {
+ fprintf (file,"%s%s",r?" ":"",argv[r]);
+ }
+ fputs ("\n", file);
+ fclose (file);
+ }
+
+ //r=execve(argv[2],argv+2,envp);
+
+ //fprintf(stderr,"Failed to run %s.\n",argv[2]);
+ //return r;
+}
--- /dev/null
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <stdio.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+int main (int argc, char **argv){
+ FILE* file;
+ int i;
+ file=fopen("/home/b/pro/runcwd/cwda.txt","w");
+ if (file != NULL) {
+ fprintf(file,"%s\n",get_current_dir_name());
+ for (i=0; i<argc; ++i) {
+ fprintf(file,"%s\n",argv[i]);
+ }
+ fclose (file);
+ }
+ printf("%s\n",get_current_dir_name());
+ for (i=0; i<argc; ++i) {
+ printf("%s\n",argv[i]);
+ }
+}