This commit is contained in:
ioacademy-jikim
2018-06-14 09:32:50 +09:00
commit 22beff8dbe
39 changed files with 22626 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := myapp.c
LOCAL_MODULE := myapp
include $(BUILD_EXECUTABLE)
+17
View File
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fd = open("__null__", O_RDWR);
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
if (fd > 2) close(fd);
printf("hello world\n");
return 0;
}
BIN
View File
Binary file not shown.
View File
+10
View File
@@ -0,0 +1,10 @@
#include <stdio.h>
//int main()
//int main(int argc, char **argv)
int main(int argc, char **argv, char **envp)
{
int i;
for(i=0; envp[i]; i++ )
printf("envp[%d]=%s\n", i, envp[i] );
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char* path = argv[0];
char* args[] = { path, 0 };
printf("before\n");
execv(path, argv);
printf("after\n");
return 0;
}
+33
View File
@@ -0,0 +1,33 @@
#if 1
#include <stdio.h>
struct aaa
{
int count;
int b[];
};
int main()
{
struct aaa *pa;
pa = (struct aaa*)malloc( sizeof(struct aaa) + sizeof(int)*10 );
pa->count = 10;
pa->b[9] = 10;
return 0;
}
#endif
#if 0
#include <stdio.h>
struct aaa
{
int a;
int b[];
};
int main()
{
struct aaa aaa;
printf("%lu\n", sizeof aaa );
return 0;
}
#endif
+345
View File
@@ -0,0 +1,345 @@
#if 1
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
void my_sig( int signo )
{
printf("my_sig(%d)\n", signo );
while( waitpid(-1,0,WNOHANG) > 0 )
;
}
int main()
{
int i,j;
signal( SIGCHLD, my_sig );
for(i=0; i<5; i++ )
{
if( fork() == 0 )
{
for(j=0; j<i+1; j++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
void my_sig( int signo )
{
printf("my_sig(%d)\n", signo );
while( wait(0) > 0 )
;
}
int main()
{
int i,j;
signal( SIGCHLD, my_sig );
for(i=0; i<5; i++ )
{
if( fork() == 0 )
{
for(j=0; j<i+1; j++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
void my_sig( int signo )
{
printf("my_sig(%d)\n", signo );
while( wait(0) > 0 )
;
}
int main()
{
int i,j;
signal( SIGCHLD, my_sig );
for(i=0; i<100; i++ )
{
if( fork() == 0 )
{
for(j=0; j<3; j++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
void my_sig( int signo )
{
printf("my_sig(%d)\n", signo );
wait(0);
}
int main()
{
int i,j;
signal( SIGCHLD, my_sig );
for(i=0; i<100; i++ )
{
if( fork() == 0 )
{
for(j=0; j<3; j++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
void my_sig( int signo )
{
printf("my_sig(%d)\n", signo );
wait(0);
}
int main()
{
int i;
signal( SIGCHLD, my_sig );
if( fork() == 0 )
{
for(i=0; i<3; i++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int i;
if( fork() == 0 )
{
for(i=0; i<3; i++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
wait(0);
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int i;
if( fork() == 0 )
{
for(i=0; i<3; i++ )
{
printf("\t\t\t\tchild\n");
sleep(1);
}
exit(0);
}
for(;;)
{
printf("parent\n");
sleep(1);
}
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
char *argv[] = { "ls", (char*)0 };
printf("prompt > ls\n");
if( fork() == 0 )
execve("/bin/ls", argv, 0);
wait(0);
printf("prompt > \n");
return 0; // exit(main());
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
char *argv[] = { "ls", (char*)0 };
printf("prompt > ls\n");
if( fork() == 0 )
execve("/bin/ls", argv, 0);
sleep(1);
printf("prompt > \n");
return 0; // exit(main());
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
char *argv[] = { "ls", (char*)0 };
printf("prompt > ls\n");
execve("/bin/ls", argv, 0);
printf("prompt > \n");
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
char *argv[] = { "ls", (char*)0 };
execve("/bin/ls", argv, 0);
printf("after\n");
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
pid_t pid;
pid = fork();
if( pid == 0 )
printf("child\n");
else
printf("parent\n");
return 0;
}
#endif
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
fork();
printf("after\n");
return 0;
}
#endif
BIN
View File
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fd = open("__kmsg__", O_RDWR);
write(fd, "hello world\n", 12);
close(fd);
return 0;
}
+13
View File
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <libgen.h>
#include <string.h>
// # /init
int main(int argc, char** argv) {
printf("%s\n", basename(argv[0]));
if (!strcmp(basename(argv[0]), "ueventd")) {
//return ueventd_main(argc, argv);
printf("ueventd\n");
}
return 0;
}
BIN
View File
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello Android\n");
return 0;
}
+12
View File
@@ -0,0 +1,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
int fd;
umask(0);
fd = open("aaa", O_CREAT| O_TRUNC | O_RDWR , 0666 );
close(fd);
return 0;
}
+20230
View File
File diff suppressed because it is too large Load Diff