- char *a;
- while (fgets(command, 1024, fp) != NULL) {
- if((a = strchr(command, '\n')))
- *a = '\0';
- if(answere_channel) {
- putsock(client, "PRIVMSG %s :%s", chan->name, command);
- } else
- reply(getTextBot(), user, "%s", command);
+ struct ClientSocket *textbot = getTextBot();
+ pid_t pID = fork();
+ if (pID == 0) { //We're the child process :D
+ char *a;
+ while (fgets(command, 1024, fp) != NULL) {
+ if((a = strchr(command, '\n')))
+ *a = '\0';
+ if(answere_channel)
+ putsock(client, "PRIVMSG %s :%s", chan->name, command);
+ else
+ reply(textbot, user, "%s", command);
+ }
+ pclose(fp);
+ exit(0);
+ } else if (pID < 0) {
+ reply(getTextBot(), user, "internal bot error - please contact an administrator!");
+ pclose(fp);
+ } else {
+ //parent bot - continue program