\x00をプログラムに入力する

メモ書き

pythonだと怒られるのでCでかいた。
ターミナルだとargvに\x00, 標準入力に\x00を
入れる事ができないのでfork+execでargvに\x00、
pipeでstdinに\x00を入れた。

pythonでのやり方が知りたい。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/uio.h>
#include <unistd.h>
#include <sys/types.h>

char *argv[4];

int main(void){
        int     fd[2];
        pid_t   pid;

        char *env[]={NULL};

        argv[0] = "/home/mizu/kiso";
        argv[1] = "\x00";

        if(pipe(fd) < 0){
            perror("pipe");
            exit(1);
        }

        pid = fork();
        if(pid < 0){
            perror("fork");
            exit(1);
        }
/*
    0 -> stdin
    1 -> stdout
*/
        // child
        if(pid == 0) {
            close(fd[1]);
            dup2(fd[0], 0);
            execve("/home/mizuki/sonoko", argv, env);
            close(fd[0]);
        }else{
            close(fd[0]);
            // "\x00" -> stdin
            write(fd[1], "\x00", 0);
        }
        return 0;
}