Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Nachbauen von popen()

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

lerne gerade auf eine C / Unix Prüfung und bin auf eine Frage gestossen, die ich nicht ganz verstehe wie ich da vorgehen soll:

Die Frage lautet: Manuelles Nachbauen von int pfd=popen("sort xy","r");

Also popen erzeigt einen Prozess, schließt automatisch nicht benutzte Enden der Pipe. Zudem will hier gelesen werden (Parameter r) Soweit ok.

Meine Idee:



int main(){

int pid, n, fd; 

int pfd[2]; /* Die Pipe */


pid=fork(); /* Neuen Prozess erzeigen */

if(pid<0){

     perror("fork");

     exit(2);

}


if( pid==0){

     close(0);

     dup(pdf[0]);

     close(pfd[1]);

    execelp("sort", "sort", "xy", NULL);

    exit(0);

}

else{

    wait();

    return 0;

}

}


Ich versteh nicht ob ich eine Dateiverbindung via open machen muss und laut popen ließt der neue Kindprozess, aber was genau? Soll er nicht die Daten an den Vater schreiben?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.